Where is Function in the prototype chain of a JavaScript function?
Working Example: In Chrome's console, I created the following function:
> var f = function() { alert(1); }
invocation with f()
correctly results an an alert of the number 1. Upon examination of the function with the following console statement:
> console.dir(f)
Notice how the prototype is listed as Object, in the form of key/value pair prototype: Object
, meaning that function f
inherits directly from Object. Fair enough; arrays and other entities in JavaScript also inherit from Object.
The conflict results from the following observation. Enter the following command:
f instanceof Function
This results in true
.
As I understand it, user-created functions inherit from the Function object, which in turn inherits from Object; however, for the life of me, I can't find it by inspecting the prototype chain for f.
Where is Function
in the prototype chain for function f?
tyvm