Timeline for Function.prototype and Funciton.__proto__
Current License: CC BY-SA 4.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 14, 2022 at 11:48 | comment | added | Perspicacious |
The reason why Function.prototype remains a Function object is due to backwards compatibility. Basically, there is a change in ES specification regarding how should a prototype object of an object be treated. For eg, in ES5, String.prototype is an String object but in ES6, its an object of type Object. The exception to such changes are "prototype objects" of Function and Array. You can read more here: stackoverflow.com/questions/32928810/…
|
|
| Mar 21, 2021 at 11:16 | comment | added | Bergi |
@pragun Use console.dir to print it as an object - Function.prototype is a function for some reason. And no, Function.prototype === Obect.getPrototypeOf(Function) isn't strange if you consider what they mean, but it's special indeed as this only happens on a "metaclass" where the class is an instance of itself.
|
|
| Mar 21, 2021 at 7:06 | comment | added | pragun | @GowthamRajJ, thanks, I had a look at Mozilla docs, but could not find something useful that sheds light on this. | |
| Mar 21, 2021 at 7:02 | comment | added | pragun | @Bergi Does this not look strange to you that the Function object has its both .__proto__ and .prototype property point to a same object. String.prototype and String.__proto__ point to two different objects. Moreover, what exactly is Function.prototype object? I can't see what is inside it. It returns ƒ () { [native code] }. Is it of type function or object. You can see what is inside Function() object, Object() and Obect.prototype object. But not this one. | |
| Mar 20, 2021 at 23:35 | review | Close votes | |||
| Mar 24, 2021 at 0:05 | |||||
| Mar 20, 2021 at 23:15 | comment | added | Bergi |
Every function (including Function() and Object()) inherits from Function.prototype, which holds function methods like .call/.apply/.bind, and in turn inherits from Object.prototype.
|
|
| Mar 20, 2021 at 19:05 | comment | added | Gowtham Raj J | This might help you understand - stackoverflow.com/questions/9959727/… & developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/… | |
| Mar 20, 2021 at 18:21 | history | asked | pragun | CC BY-SA 4.0 |