52 lines
1.5 KiB
Markdown
52 lines
1.5 KiB
Markdown
---
|
||
title: Math Max
|
||
localeTitle: الرياضيات ماكس
|
||
---
|
||
## الرياضيات ماكس
|
||
|
||
`Math.max()` دالة تقوم بإرجاع أكبر قيمة من قائمة القيم الرقمية التي تم تمريرها كمعلمات. إذا تم تمرير قيمة غير رقمية كمعلمة ، `Math.max()` `NaN` .
|
||
|
||
يمكن تمرير صفيف من القيم الرقمية كمعلمة مفردة إلى `Math.max()` باستخدام أي من `spread (...)` أو `apply` . ومع ذلك ، قد تفشل أي من هاتين الطريقتين عندما يكون مقدار قيم الصفيف عاليًا جدًا.
|
||
|
||
### بناء الجملة
|
||
|
||
`Math.max(value1, value2, value3, ...);
|
||
`
|
||
|
||
### المعلمات
|
||
|
||
أرقام ، أو مجموعة محدودة من الأرقام.
|
||
|
||
### قيمة الإرجاع
|
||
|
||
أعظم القيم الرقمية المعطاة ، أو `NaN` إذا كانت قيمة معينة غير رقمية.
|
||
|
||
### أمثلة
|
||
|
||
_الأرقام كمعلمات_
|
||
|
||
`Math.max(4, 13, 27, 0, -5); // returns 27
|
||
`
|
||
|
||
_معلمة غير صالحة_
|
||
|
||
`Math.max(4, 13, 27, 'eight', -5); // returns NaN
|
||
`
|
||
|
||
_صفيف كمعلمة ، استخدام السبريد (…)_
|
||
|
||
`let numbers = [4, 13, 27, 0, -5];
|
||
|
||
Math.max(...numbers); // returns 27
|
||
`
|
||
|
||
_صفيف كمعلمة ، باستخدام تطبيق_
|
||
|
||
`let numbers = [4, 13, 27, 0, -5];
|
||
|
||
Math.max.apply(null, numbers); // returns 27
|
||
`
|
||
|
||
#### معلومات اكثر:
|
||
|
||
[MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) |