What is a JavaScript apply() Method?

JavascriptWeb DevelopmentFront End Technology

javascript apply() method is the same as call() method, but it considers functions parameters as an array. You can try to run the following code learn how to implement apply() method in JavaScript −

Example

Live Demo

<html>
   <head>
      <script>
         document.write("The highest number in the array list: ");
         document.write(Math.max.apply(null,[50,90,18, 87]));
         document
      </script>
   </head>
   
   <body>
   </body>
</html>

Output

The highest number in the array list: 90
raja
Published on 16-Feb-2018 16:37:06
Advertisements