Function
A function is an object, and the object that represents the function is the function object. All function objects are constructed from function objects. In other words, the function is the topmost constructor. It constructs all the objects in the system, including user-defined objects, system-built objects, and even its own.
Object
The object is the topmost object, and all objects inherit the prototype of object, and you know that object is also a function object, so that object is constructed by function.
Function and Object diagram:
Copy Code code as follows:
<script type= "Text/javascript" >
var foo= function () {}
var f1 = new Foo ();
Console.log (f1.__proto__ = = = Foo.prototype);
Console.log (Foo.prototype.constructor = = = Foo);
var O1 =new Object ();
Console.log (o1.__proto__ = = = Object.prototype);
Console.log (Object.prototype.constructor = = = Object);
Console.log (foo.prototype.__proto__ = = = Object.prototype);
Function and Object
Console.log (function.__proto__ = = = Function.prototype);
Console.log (object.__proto__ = = = Function.prototype);
Console.log (object.prototype.__proto__);
Console.log (object.__proto__ = = = Function.prototype);
</script>
Small partners to read the code when you can refer to the picture on the diagram, I hope you like.