Analyze the apply method and call method of JavaScript Functions from JQuery source code _ javascript skills

Source: Internet
Author: User
This article mainly introduces how to analyze the apply and call methods of JavaScript Functions from JQuery source code. This article explores the apply and call methods again by combining JQuery source code and js advanced programming, for more information, see $. when the each method is very, suddenly think of $. each ($ ('P'), function (index, entity) {}); where did the index and entity come from, and they are dispensable, in addition, such a high level tells us the subscript and instance of the current traversal. So let's take a look at the jQuery source code, which is written in this way:

During debugging, the Code marked with red is used, and then the callback. call function is used. So I looked at js advanced programming, which has a deep explanation.

First, a function is a pointer to a Function object, and a function name is a pointer to a Function. In the function body, there will be a scope, that is, the this keyword.

This keyword indicates the function running scope. For example:

The Code is as follows:


Related Article

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.