ES6 - Math.log2(x) Function



Returns the base 2 logarithm of X.

Syntax

Math.log2(x)    

Parameter

  • X − represents a number

Example

console.log("---Math.log2()---") 
console.log("Math.log2(2): "+Math.log2(2)) 
console.log("Math.log2(5): "+Math.log2(5))         

Output

---Math.log2()--- 
Math.log2(2): 1 
Math.log2(5): 2.321928094887362           
Advertisements