Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is function Empty() {}?

In Chrome,

(function(){}).__proto__

is

function Empty() {}

so I would have expected

new Function();

to be function Empty() {}, but instead it is function anonymous() {}.

Where can I find function Empty() {}? Is it in Function or Object somewhere?

like image 807
Randomblue Avatar asked Dec 08 '22 21:12

Randomblue


1 Answers

Those names don't mean you can access them with those identifiers.

As for the prototype of a function, the name is set at startup. That function has been set a name but it doesn't really serve any purpose other than .name and .toString() exposing it.

As for a new Function() instance, the name is merely printed for .toString(). So .name is still the empty string. Again, it doesn't serve much purpose.

like image 98
pimvdb Avatar answered Dec 11 '22 09:12

pimvdb