@
and @@
This module provides an Ruby style aliases for:
this
in the form of@
this.constructor
in the form of@@
Example
Animal = (type, color) { @type = type @color = color @@count += 1 @@all.push @ }
@ in bang function calls
In the case of unwrapped async calls via the bang
postfix, @
will actually refer to the outer this
.
Since we can refer to both via this method, binding becomes unecessary.
Example
Class.cacheData = { d = $.get! "/" @data = d // outer this this.data = d // inner this return @ }