On function and object_javascript skills in JavaScript

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.