Use of@in variables

Asked

Viewed 113 times

9

I see in some languages that compile for javascript, such as Typescript and Coffeescript, the use of @ variables, as well as cases where it is not used. For example:

w = 10;
@v = 11;

After all, what is the point of @ and the difference between using it or not?

2 answers

7


In Javascript, this means nothing, not even a valid variable identifier (like $ or _).

In the Coffeescript, the @ is the same thing as this. Only syntactic sugar.

In Typescript, the @ inherited from Atscript. In this case it is a decorator, like those in Python.

3

They are decorators of functions and properties. When you use a decorator adds or changes the shape with the function or property works.

Although they look like java annotations and attributes of C#, is it really looks like the python decorator.

Only available from Ecmascript 6.

Implementation proposal from him which is where I saw something more canonical about him.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.