什么是JavaScript apply()方法

什么是JavaScript apply()方法

javascript的apply()方法与call()方法相同,但它把函数参数看作是一个数组。你可以尝试运行下面的代码,学习如何在JavaScript中实现apply()方法。

示例

<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>
HTML

输出

The highest number in the array list: 90
HTML

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

JavaScript 教程

登录

注册