Dlaczego math.max działa tylko z siecią dystrybucji w javascript

Przykłady kodu

0
0

użyj operator dystrybucji w max metodzie 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. 

Podobne strony

Podobne strony do przykłady

W innych językach

Ta strona jest w innych językach

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