JS Math.log2()
🌙
手机阅读
本文目录结构
概述
Math.log2()
函数返回一个数字以 2 为底的对数.
语法
Math.log2(x)
参数
x
任意数字.
描述
如果传入的参数小于 0, 则返回 NaN
.
示例
Math.log2(2) // 1
Math.log2(1024) // 10
Math.log2(1) // 0
Math.log2(0) // -Infinity
Math.log2(-2) // NaN
Math.log2("1024")// 10
Math.log2("foo") // NaN
规范
Specification | Status | Comment |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262)Math.log2 | Standard | Initial definition. |
相关链接
Math
对象.