The relationship between object and function in JavaScript

Source: Internet
Author: User

First look at a few examples:

// true    //  True  indicates that object is constructed by function  //True to  indicate that it is constructed by itself  //  true//  null
var New  //Foo is a constructor of Foo / /// But function is not a constructor of Foo // //functionis Foo's constructor alert (foo instanceof function);   // true

Function and object are both functions, because they can be executed by function () or object (), because they can be assigned FUNCTION.A = ' a ', object.a = ' a '.

They are functions because they are derived from the "built-in function factory" described in 4th above, and thus have the characteristics of functions.

Said they were the object. Because they are derived from the "root" object in the 1th above, thus possessing the characteristics of the object.

To keep talking, function.prototype points to "built-in functions". and Object.prototype points to "source object."

For object, which is the topmost object, all objects inherit the prototype of object, but you also have to know explicitly that object is a function object, so object is constructed by function;

There is a picture on the web that can be explained in detail:

The relationship between object and function in JavaScript

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.