“@”符号在Javascript,Coffeescript或Jquery中有特殊含义吗?

我有一些代码看起来像

self = @

然后再使用@someMethodName或self.someMethodName

@有一些特殊的含义吗?

@不是JavaScript标识符的有效字符。标识符只能包含$,_,数字和字母。

在coffeescript,@ means this

CoffeeScript has a few nice features related to the this keyword.
First, CoffeeScript uses the @ symbol as shorthand for this.. For
example, @foo is equivalent to this.foo. Second, if you use the @
symbol in the parameters of a function, CoffeeScript will
automatically assign those values as properties of the object.

编辑:就jQuery而言,与javascript一样的标识符规则适用,因为jQuery只是javascript。有关jQuery中@的其他用途,请参阅this questionthe docs

翻译自:https://stackoverflow.com/questions/14143123/does-the-symbol-have-special-meaning-in-javascript-coffeescript-or-jquery

转载注明原文:“@”符号在Javascript,Coffeescript或Jquery中有特殊含义吗?