JavaScript Function apply() methodThe JavaScript Function apply() method is used to call a function contains this value and an argument contains elements of an array. Unlike call() method, it contains the single array of arguments. SyntaxParameterthisArg - It is optional. The this value is given for the call to a function. array - It is optional. It is an array-like object. Return ValueIt returns the result of the calling function along provided this value and arguments. JavaScript Function apply() method ExampleExample 1Let's see an example to determine the maximum element. Test it NowOutput: 9 Example 2Let's see an example to determine the minimum element. Test it NowOutput: 1 Example 3Let's see an example to join arrays of same type. Test it NowOutput: 1,2,3,4,5,6,7,8 Example 4Let's see an example to join array of different type. Test it NowOutput: 1,2,3,4,One,Two,Three,Four Next TopicJavaScript Function |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India