| 标题 | 标签 |
|---|---|
| isNegativeZero(是否负零) | math(数学) |
检查给定值是否等于负零 (-0)。
- 检查传递的值是否等于 0,以及 1 除以该值是否等于 -Infinity。
const isNegativeZero = val => val === 0 && 1 / val === -Infinity;ts 代码如下:
调用方式:
isNegativeZero(-0); // true
isNegativeZero(0); // false应用场景
以下是一个实战示例:
结果如下:
<iframe src="codes/javascript/html/is-negative-zero.html"></iframe>