Three roles of JS Learning summary----function

Source: Internet
Author: User

Note: Function.prototype is the value of the function data type, but the related operation is exactly the same as before->empty/anonymous

The function itself will have its own properties:

Length: The number of formal parameters

Name: Name of "Fn" function

Prototype of the prototype class, the method defined on the prototype is the public method of the current FN class instance.

__proto__ functions as a normal object, pointing to the prototype of the function class.

function is the most complex and important knowledge in the whole JS:

1, a function has a multi-faceted nature:

    "Normal function": itself is a normal function, the execution of the time will form a private scope (closure), parameter assignment, pre-interpretation, code execution, after the completion of the stack memory destroyed/not destroyed

    "Class": It has its own instance, and there is a prototype called the prototype property, and his instance can point to his own prototype

    "Normal Object": Like obj in var obj = {}, it is an ordinary object that can have its own private property as an object, or it can be found by __proto__ Function.prototype

There is no definite relationship between the three of them.

functionFn () {varnum = 500;  This. x = 100; } Fn.prototype.getX=function() {Console.log ( This. X)} FN.AAA= 1000; varf =NewFn; F.num//undefinedF.aaa//undefined        varres =Fn (); Res//undefinedFn.aaa// +

JS Learning summarizes the three roles of----functions

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.