Por que não a matemática.max só funcionam em um diferencial do operador em javascript

Exemplos de código

0
0

use espalhar operador max método 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. 

Páginas relacionadas

Páginas semelhantes com exemplos

Em outros idiomas

Esta página está em outros idiomas

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