In his Eloquent Javascript, Haverbeke claims that (page 16):
\"In a JavaScript system, most of this data is neatly separated into things called va
They're a type of object.
The typeof
is "function"
:
typeof (function() {}) === "function" // true
The internal [[Class]]
is [object Function]
:
({}).toString.call(function() {}) === "[object Function]" // true
They're an instance of the Function
constructor prototype:
(function(){}) instanceof Function // true
They're an instance of the Object
constructor prototype:
(function(){}) instanceof Object // true