Math.log2

log2 — Returns the base 2 logarithm of a number.

Description

Math.log2(number number)

Parameters

Name Description Type Default Optional
number number No

Examples

Example #1 – log2 example
console.log(Math.log2(3)); // 1.584962500721156 console.log(Math.log2(8)); // 3 console.log(Math.log2(-3)); // NaN

External references