"Front-end learning" functional programming related

Source: Internet
Author: User

    • The length property of the Function object returns the number of parameters of the time functions, and the length property of the arguments object returns the number of arguments for the function. If the function is not an anonymous function, Arguments.callee is equivalent to the function name.
    • About Call and apply

   function f () {

THIS.A = ' a ';

this.b = function () {

Alert (' B ')

}

}

function e () {

F.call (this);

alert (a);

}

E ()//' a '

The above example shows that if the external function is called dynamically using the call and apply methods within the function body and the first parameter issued by the call,apply is set to this, then the current function e inherits all members of F, using call, The Apply method can copy the internal variables of the calling function to the current function body, changing the internal this point of function f to function E, so that e can refer to the F internal members.

    • Function call pattern
      • Method invocation pattern. When a function is saved as a property of an object, it becomes a method. When a method is called, this is bound to the current object.
      • The function invocation pattern. When a function is not a property of an object, it is invoked as a function. This binds to the global object.
      • constructor invocation mode. If the call is preceded by the new operator in front of a function, a new instance object that hides the prototype prototype object linked to the function is created, and this is bound to the new instance object. (constructor function usually starts with uppercase letters)
      • The Apply invocation pattern. Use this method to call the function and modify the function body this value.

"Front-end learning" functional programming related

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.