Computer >> Computer tutorials >  >> Programming >> Javascript

What is a JavaScript apply() Method?


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

<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