Difference between Function.prototype.apply and Function.prototype.call Last Updated : 09 Jan, 2023 Comments Improve Suggest changes Like Article Like Report JavaScript treats everything as an object, even functions, and every object has its own properties and methods. Function objects have both apply() and call() methods on them. However, there is confusion about the two functions in JavaScript. The main difference between them is how they handle function arguments. There is no difference between these two functions in how the arguments are passed to the called function, but the definition inside the function differs. In addition to the first parameter, apply() requires an array as its second parameter. The arguments to the target method are represented as an array. JavaScript call() Function: It uses given arguments and values to call a function Syntax: function.call(object, arg1, arg2) Example: JavaScript let obj = { fname: "geeks", mname: "for", lname: "geeks", }; let display = function (str1, str2) { console.log(`${str1} ${str2} ${this.fname + this.mname + this.lname}`); }; display.call(obj, "Welcome", "to"); Output: Welcome to geeksforgeeks JavaScript apply() Function: This method is used to call a function with arguments and values as arrays or array objects. In both cases, the first argument will be the object reference that represents 'this' inside the called function. Therefore, the call() is different from apply(). Each can be applied to a function, which runs within the context of the first argument. In call(), the remaining arguments are passed into the function as is, whereas, in apply(), the second argument will be an array that the called function will unpack as arguments. Syntax: function.apply(object, [arg1, arg2]) Example: JavaScript let obj = { fname: "geeks", mname: "for", lname: "geeks", }; let display = function (str1, str2) { console.log(`${str1} ${str2} ${this.fname + this.mname + this.lname}`); }; display.apply(obj, ["Welcome", "to"]); Output: Welcome to geeksforgeeks Difference between Function.prototype.apply and Function.prototype.call: Function.prototype.apply() Function.prototype.call() Using the apply() method, one can call a function with a specified value as well as arguments provided in the form of an array (or object). Using call(), a function is called with the given value and arguments. function.call(object, arg1, arg2)function.apply(object, [arg1, arg2]) Comment More infoAdvertise with us Next Article Difference between Function.prototype.apply and Function.prototype.call debadebaduttapanda7 Follow Improve Article Tags : Difference Between JavaScript Web Technologies JavaScript-Methods JavaScript-Questions Web Technologies - Difference Between +2 More Similar Reads Difference between proto and prototype In this article, we will be going to cover the topic what is proto and prototypes, their syntax, examples, and what are differences exist between both, and how they differ and how they differ in different aspects. Proto and prototype both are objects that help in whether creating an array, object, 3 min read Difference Between Array.prototype.map() and Array.prototype.flatMap() in JavaScript In JavaScript, Array.prototype.map() and Array.prototype.flatMap() are both the methods used to the transform elements in arrays but they differ in their behaviors regarding handling and flattening of the nested arrays.What is Array.prototype.map()?The map() method creates a new array populated with 3 min read What is the difference between call and apply in JavaScript ? JavaScript call() Method: It calls the method, taking the owner object as an argument. The keyword this refers to the 'owner' of the function or the object it belongs to. We can call a method that can be used on different objects. Syntax: object.objectMethod.call( objectInstance, arguments ) JavaScr 2 min read Difference Between Objects and Prototypes in JavaScript Objects in JavaScriptThe Objects in JavaScript are instances of the class or constructors and they can hold properties and methods. These properties and methods can be unique to the object or inherited from the prototypes. The Objects can be created using the constructor functions, object literals, 3 min read Difference Between Function Overloading and Function Overriding in JavaScript Function overloading and function overriding are two important concepts in object-oriented programming (OOP). Function overloading allows the creation of multiple functions with the same name but different parameters. Function overriding allows the subclass or child class to provide the specific imp 3 min read Difference between Class.method and Class.prototype.method JavaScript is an object-oriented programming language, but unlike its peers (which are class-based), JavaScript is a prototype-based language. It means that in JavaScript, you can create an object (prototype object) that acts as a template for new objects. These new objects can be provided with new 2 min read Difference between Methods and Functions in JavaScript Grasping the difference between methods and functions in JavaScript is essential for developers at all levels. While both are fundamental to writing effective code, they serve different purposes and are used in various contexts. This article breaks down the key distinctions between methods and funct 3 min read Difference between âfunction declarationâ and âfunction expression' in JavaScript Functions in JavaScript allow us to carry out some set of actions, important decisions, or calculations and even make our website more interactive. In this article, we will learn the difference between âfunction declarationâ and âfunction expressionâ. The similarity is both use the keyword function 2 min read Difference Between instanceof and isPrototypeOf() in JavaScript In JavaScript, understanding object relationships and type checks is crucial for the effective programming. The Two methods that facilitate these checks are instanceof and isPrototypeOf(). While both are used to the determine the type or prototype relationships in the JavaScript they operate differe 2 min read Difference between Anonymous and Named functions in JavaScript In JavaScript or in any programming language per say, functions, loops, mathematical operators and variables are the most widely used tools. This article will tell you about the difference between anonymous functions and named functions. We will discuss all the required concepts in this article to k 4 min read Like