Skip to content

Instantly share code, notes, and snippets.

@mboeh
Created September 26, 2012 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mboeh/3790960 to your computer and use it in GitHub Desktop.
Save mboeh/3790960 to your computer and use it in GitHub Desktop.
just for the sake of clarification
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