Object.create() VS functions

Brandon Benvie bbenvie at mozilla.com
Sat Oct 26 08:06:23 PDT 2013


On 10/26/2013 7:44 AM, Michaël Rouges wrote:
> Knowing that every function is an object, I am surprised that the 
> Object.create() method doesn't really allow cloning function.

Object.create creates Objects. You run into the same limitation when 
trying to create Arrays with Object.create (doesn't work correctly). 
You're looking for Function.create [1], which doesn't yet exist 
(although you can get pretty close using Proxies for functions).

[1] A sample implementation of Function.create can be found on 
http://wiki.ecmascript.org/doku.php?id=strawman:name_property_of_functions


More information about the es-discuss mailing list