Instantly remember the difference between apply and call in JavaScript

Source: Internet
Author: User

On the use of the JavaScript function and the call method, there are many articles on the Internet, I do not have many words. Apply and call function very similar, but the way of use is different

The first parameter of apply and call is an object, which is used to swap the function itself for this point, which is the alias.

Starting with the 2nd argument is the argument passed to the function. The difference between apply and call is in this parameter form, one is to put all the parameters into an array, one is written in turn.

First, the following:apply accepts the array form of the parameter set, call is to write the parameters in sequence .

The egg hurts is I often can't remember whether to apply an array form or call with an array form, use when a confused need to check the data to determine.

Today, suddenly found to be very good to remember, so share to have the same distress of people:

Apply, the first letter is A, and the array is the word array , the first letter is also a, so apply accepts the parameters in the form of an array.

It's easy to correspond. Anyway, I will not be confused later.

This article from: http://jo2.org/%E7%9E%AC%E9%97%B4%E8%AE%B0%E4%BD%8Fjavascript%E4%B8%ADapply%E4%B8%8Ecall%E7%9A%84%E5%8C%BA%E5%88%AB/

Instantly remember the difference between apply and call 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.