Created
September 26, 2012 22:13
-
-
Save mboeh/3790960 to your computer and use it in GitHub Desktop.
just for the sake of clarification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What I mean is that even though JS method invocation seems to work like this: | |
(obj.method)(args) | |
it's a bit trickier than that. See this: | |
> a = {} | |
> a.toString() | |
"[object Object]" | |
> (a.toString)() | |
"[object Object]" | |
> z = a.toString | |
> z() | |
"[object global]" | |
That is: there's a difference between invoking obj.meth versus just retrieving the obj.meth property and invoking it using (). | |
In either case, there's nothing keeping CoffeeScript from parsing | |
obj.meth | |
as | |
obj.meth() | |
except for the desire to maintain certain levels of parity with JavaScript's syntax. (It'd always be possible to obtain the implementation of obj.meth with obj['meth'], FWIW.) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment