Interpretation: myfunc
is a function object auto created by JS interpreter internally whenever a new function like myfunc
is declared as shown above.
Almost, but not quite. myfunc
is an identifer that refers to (points to) a function created by the JavaScript engine.1 That function is an object, because all functions are objects in JavaScript. You could call it a "function object" if you like; most people would just call it a "function." (In JavaScript "function" and "function object" are synonyms.)
var myObj = new myfunc();
var mynewObj = new myfunc();
Interpretation: myObj
and mynewObj
are instances(objects) of myfunc
thus can be said to be a function objects
No, they're not function objects. They're just objects. They are indeed instanceof myfunc
which means that the object myfunc.prototype
points to is in their prototype chain, but it's not correct at all to call them "function objects" because they aren't functions.
1 "JavaScript engine" - This is the term I use in preference to "JavaScript interpreter" because any modern JavaScript engine is a just-in-time-compiler plus runtime environment, not an interpreter. It's a subtle distinction.
In a comment, Jamie Dixon mentions the Function
function. It's just a function that creates functions based on source code strings. There are virtually no use cases for it in modern JavaScript (just as there are virtually no use cases for eval
in modern JavaScript).