概述
Number.MIN_VALUE 属性表示在 JavaScript 中所能表示的最小的正值。
Number.MIN_VALUE 属性的属性特性: |
|
|---|---|
| writable | false |
| enumerable | false |
| configurable | false |
描述
MIN_VALUE 属性是 JavaScript 里最接近 0 的正值,而不是最小的负值。
MIN_VALUE 的值约为 5e-324。小于 MIN_VALUE ("underflow values") 的值将会转换为 0。
因为 MIN_VALUE 是 Number 的一个静态属性,因此应该直接使用: Number.MIN_VALUE, 而不是作为一个创建的 Number 实例的属性。
示例
例子:使用 MIN_VALUE
下面的代码里两个数值相除。如果结果大于或等于 MIN_VALUE,则调用 func1 函数;否则,调用 func2 函数。
if (num1 / num2 >= Number.MIN_VALUE) {
func1();
} else {
func2();
}
规范
| 规范版本 | 规范状态 | 注解 |
|---|---|---|
| ECMAScript 1st Edition. Implemented in JavaScript 1.1 | Standard | Initial definition. |
| ECMAScript 5.1 (ECMA-262) Number.MIN_VALUE |
Standard | |
| ECMAScript 2015 (6th Edition, ECMA-262) Number.MIN_VALUE |
Standard |
浏览器兼容性
We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains.
Find out how you can help!
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |