In JavaScript is Object the root of all entities or Function is the root?
For example in the following source objects-functions-and-prototypes-in.html, first the author says “Every entity in Javascript is an object”, and later it says “any new object can only be created as an instance of a function (even when you do ‘var a = new Object;’, Object is a function btw)”. The author is basically contradicting himself as far as I can see.
And I see the same chaotic comments in so many other resources on JavaScript. In Java it is easy, you know the first entity in any class Hierarchy is the Object class, but in JavaScript, all I see is chaos.
So, can someone please clarify if Object comes first or Function? What is the root.
I believe the end of the line is
Object.prototype, which is an object. This is what makes me think so:The ECMAScript 5.1 specification states it like this:
In 15.3.4 Properties of the Function Prototype Object:
And in 15.2.4 Properties of the Object Prototype Object