When I try to access the Prototype property of functions it gives me the following result:
console.log(Function.prototype); // () { [native code] }
But when I perform the same operation on other objects like Arrays it shows me the actual prototype of Array where all the methods are linked
console.log(Array.prototype); // [constructor: ƒ, concat: ƒ, copyWithin: ƒ, fill: ƒ, find: ƒ, …]
What I really want to know is why the Functions behave differently.
Logging functions with
console.logwill log the text of the function. If the function is not written in JavaScript - for example, like here, if the implementation is provided by the environment - it'll give you[native code]instead.But there's an easy way to log at the properties on the function, at least in Chrome: use
console.dir.which gives you the function properties as expected, at least in both Chrome and FF.
The functionality of this
Function.prototypeis described here.