ทำไมคณิตศาสตร์แม็กซ์ทำงานอยู่บนกระจายโอเปอเรเตอร์อยู่ในจาวาสคริปต์

รหัสตัวอย่าง

0
0

ใช้กระจายโอเปอเรเตอร์แม็กซ์อยู่ในวิธีการจาวาสคริปต์

// 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
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังหน้ากับตัวอย่างอยู่ในหมวดหมู่