为什么数学。max只能在一个传播运营商在javascript

代码示例

0
0

使用扩散操作员在最大的方法javascript

// Inbuilt method Math.max() is the most common method used to find a maximum value in an array.
//Every value of an array is sent into the Math function

var array = [1,2,3];
      var Max1 = Math.max(array);
      var Max2 = Math.max(array[1],array[1],array[2]) ;
      document.write(Max1);
      document.write(Max2);

//Output :
//NaN
//3

//it works similar if we use spread operator we don't have to pass each value

var array = [1,2,3];
      var Max1 = Math.max(array);
      var Max2 = Math.max(...array) ;
      document.write(Max1);
      document.write(Max2);

//Output :
//NaN
//3


//spread operator (...) is used instead of sending each value into math function. 

类似页面

带有示例的类似页面

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................