JavaScript Apply() Function Last Updated : 26 May, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The apply() method is used to write methods, which can be used on different objects. It is different from the function call() because it takes arguments as an array. Syntax: apply() Return Value: It returns the method values of a given function. Example 1: This example illustrates the apply() function without arguments. JavaScript let student = { details: function () { return this.name + this.class; } } let stud1 = { name: "Dinesh", class: "11th", } let stud2 = { name: "Vaibhav", class: "11th", } let x = student.details.apply(stud2); console.log(x); Output: Vaibhav 11th Example 2: This example illustrates the apply() function with arguments. JavaScript let student = { details: function (section, rollnum) { return this.name + this.class + " " + section + rollnum; } } let stud1 = { name: "Dinesh", class: "11th", } let stud2 = { name: "Vaibhav", class: "11th", } let x = student.details.apply(stud2, ["A", "24"]); console.log(x); Output: Vaibhav 11th A 24 Supported Browser: Chrome 1 and aboveEdge 12 and aboveFirefox 1 and aboveInternet Explorer 5.5 and aboveOpera 4 and aboveSafari 1 and above Comment More infoAdvertise with us Next Article JavaScript Apply() Function R riarawal99 Follow Improve Article Tags : JavaScript Web Technologies Similar Reads JavaScript Handler apply() Method JavaScript handler.apply() method in JavaScript is used as a trap for a function call. The value returned by this method is used as the result of a function call through a proxy. Syntax: const p = new Proxy(target, { apply: function(target, thisArg, argumentsList) { } }); Parameters: This method acc 2 min read JavaScript Reflect apply() Method Javascript Reflect.apply() method is a standard build-in object in JavaScript which is used to call a function using the specified argument. It works similar to the Function.prototype.apply() method to call a function, but in an efficient manner and easy to understand. Syntax: Reflect.apply(target, 2 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 Java 8 Features - Complete Tutorial Java 8 is the most awaited release of the Java programming language development because, in the entire history of Java, it has never released that many major features. It consists of major features of Java. It is a new version of Java and was released by Oracle on 18 March 2014. Java provided suppor 9 min read HashMap replaceAll(BiFunction) method in Java with Examples The replaceAll(BiFunction) method of HashMap class replaces each value with the result of applying the given function(performs a certain operation) on the corresponding value. This process continues in the same manner until all the entries have been processed or until an exception is thrown by the f 3 min read Like