🔢Infinity
const M = Number.MAX_VALUE; // = 1.7976931348623157e+308 ≈ 2¹⁰²⁴
const D = Math.pow(2, 970); // 2⁹⁷⁰
const d = Math.pow(2, 969); // 2⁹⁶⁹
// -------- Infinity --------
1 / 0, // Infinity
-1 / 0, // -Infinity
Infinity === Number.POSITIVE_INFINITY, // true
-Infinity === Number.NEGATIVE_INFINITY, // true
3 + Infinity, // Infinity
3 / Infinity, // 0
-3 / Infinity, // -0
Infinity / Infinity, // NaN
// -------- Number.MAX_VALUE --------
M, // 1.7976931348623157e+308
// ⭐️ 只要 M 的最後一位 (2⁹⁷¹) 的一半 = 2⁹⁷⁰ 就足以讓 M 「進位」變成 Infinity
M + D, // Infinity
// ⭐️ 再小的話,則會被直接「捨棄」。
M + d, // M
// -------- Number.MAX_SAFE_INTEGER --------
Number.MAX_SAFE_INTEGER, // 9007199254740991 = 2⁵³ - 1
Math.pow(2, 53) - 1, // 9007199254740991Last updated