Syntactic sugar for using a function as if it were a method of its first argument

Claude Pache claude.pache at gmail.com
Tue May 27 08:54:32 PDT 2014


Le 27 mai 2014 à 17:04, Jasper St. Pierre <jstpierre at mecheye.net> a écrit :

> 
> (...) Namely, the whole ('elements') looks like a method call containing one argument, rather than having a secret hidden argument as its first.
> 

Yes, it was exactly intended to appear as such, making `obj.{Object.getOwnPropertyDescriptor}('elements')` similar to `obj.hasOwnProperty('elements')`, for instance. If it helps, you could think of `foo.{Bar.baz}` as defining a temporary method: `(function(...args) { return Bar.baz(this, ...args) })`, or: `Bar.baz.bind(Bar, foo)`.

—Claude



More information about the es-discuss mailing list