call, apply All belong to Function.prototype One way , It is JavaScript The engine's internal implementation , Because it belongs to Function.prototype, So each Function Object instances , That is, every method has call, apply attribute . As a property of a method , Then, of course, their use is for methods . These two methods are easily confused , Because they work the same way , It's just used in different ways .

The same thing : The two methods work exactly the same , The first parameter is an object ;

Difference : From the second parameter

call() Method parameters are passed to the borrowed method in turn as parameters , namely fn.call(thisobj, arg1,arg2,arg3...argn), Yes n Parameters

apply() The first parameter of the method is the object , The second parameter is the array fn.apply(thisobj,arg), Here arg Is an array , There are only two parameters


call, apply The function is to use someone else's method to call , It's like calling your own .( hold this Given to the incoming object )

elementary analysis call and apply More related articles on different topics

  1. elementary analysis call and apply

    call, apply All belong to Function.prototype One way , It is JavaScript The engine's internal implementation , Because it belongs to Function.prototype, So each Function Object instances , It's just ...

  2. 【Web】 elementary analysis JQuery Of apply(), call(), bind() Method

    Original address :https://blog.csdn.net/whuzxq/article/details/64166253 Because in understanding this These methods appear many times , I don't understand these methods very well ...

  3. js object , Prototype ,call,apply elementary analysis

    // Object direct quantity , The easiest way to create an object is in js In this paper, we use object direct quantity var book = { "main title": "js", // There are spaces in the properties , Use quotation marks &q ...

  4. Angular Learning notes : First time to know $digest , $watch , $apply, Analysis of usage .

    The traditional browser event loop : The browser itself has been waiting for events , And respond . If you click on one button Or in input Enter the characters in the , We are JS in Listen for these events and set the callback function , So when these events are triggered , The callback function is ...

  5. Javascript in call、apply Function analysis

    call/apply The function is to change this The value of , There is a saying that : Who called this method? In that method this It means who , And sometimes we need to change this value , therefore call/apply Can be used . Now I'll write a way to ...

  6. this,call,apply,bind elementary analysis

    stay JS in ,this Pointing is a difficult point , In this article, I will explain several common this Point to the problem , And introduce call,apply,bind The usage of these three functions . One . common this Point to the situation The first thing to understand is , It's only in functions that th ...

  7. 【 Explain profound theories in simple language jQuery】 Source analyses 2-- Exotic curiosity-a solution looking

    I've been studying jQuery Source code , At first glance, the source code is confused and confused , It's really wonderful to really calm down and read it carefully , Let you sigh the beauty of code . Its structure is clear , High cohesion . Low coupling , Excellent performance and convenient scalability , Browser compatibility ( Functional defects . gradually ...

  8. Android Development of Theme、Style Exploration and source analysis

    1 background Some time ago, a partner in the group asked about Android In development Theme And Style The problem of , Of course , This kind of thing searches a large number of templates on the Internet , So I don't want to explain too much about how to use it , We focus here on understanding ...

  9. 【 Explain profound theories in simple language jQuery】 Source analyses 2-- Using skills

    I've been studying jQuery Source code , At first glance, the source code is confused and confused , It's really wonderful to really calm down and read it carefully , Let you sigh the beauty of code . Its structure is clear , High cohesion . Low coupling , Excellent performance and convenient scalability , Browser compatibility ( Functional defects . gradually ...

Random recommendation

  1. Remote login , Unable to load explorer

    I don't know why , When logging on to the server remotely , Unable to log on to the desktop , Only use mstsc.exe /admin To log in or press (CTRL+ALT+END) Enter task management , New run explorer.exe To log on to the desktop ...

  2. iTOP-4412 Development board image burning

    Image is the executable package generated after source code is compiled and connected , Burn these image files into the memory chip of the development board , Power on and it will run . There are two ways to burn , adopt TF Card burning and use OTG Interface burning OTG The way : Only in WIN7 perhaps XP ...

  3. Contest2037 - CSU Monthly 2013 Oct (problem A :Small change)

    [ Answer key ]: Binary split Any integer can be split into 2^0 + 2^1 + 2^2 + 2^3 + ....+ m [code]: #include <iostream> #include & ...

  4. Name of all columns in the key 、DB User table in

    One . Retrieve the names of all columns in a table SELECT name FROM syscolumns WHERE ID = OBJECT_ID('Departments') syscolumns (sys.sysco ...

  5. Ajax Sort out the summary ( introduction )

    Ajax Learning points : 1.Ajax summary 2.load() Method 3.$.get() and $.post() 4.$.getScript() and $.getJSON() 5.$.ajax() Method 6. Form serialization ...

  6. Lsyncd - Real time file synchronization tool ( Precise translation )

    original text : http://axkibe.github.io/lsyncd/ describe Lsyncd Monitor local tree event monitor interface (inotify or fsevents). It gathers and combines events for a few seconds , Then generate a ( Or more ...

  7. ASP.NET Core Quick start ( Environment chapter )

    [ Affirming ]: I am .NET Core The small white .Linux The small white .MySql The small white .nginx The small white . And today I'm going to say it's for you to master Linux ... Power on and power off .nginx Installation and deployment .Core Of Hello World .. ...

  8. iOS---------- It is forbidden to input Chinese characters

    explain : ^.*[\u4e00-\u9fa5].*$ Include Chinese or not ^[\u4E00-\u9FA5]+$ Is it all in Chinese - (BOOL)textField:(UITextField *)textField ...

  9. When security encounters java

    The title is taken casually Today I saw an article about java Of xss, There is also an interview question , I happened to have been asked this question . I can't help but think of some of the past and java Related security interview questions . Today, , A lot of big companies , Because of my own department ...

  10. Native js Development Notes

    1. Basic dom operation var a=document.getElementById('ma1').innerHTML;/ obtain html Code alert(document.getElementById('m ...