Page 69 - JavaScript
P. 69
6
Stage 3 ES2016 (ECMAScript 7) Proposal:
let a = 2,
b = 3,
c = a ** b;
c will now be 8
Use Math.pow to find the nth root of a number.
Finding the nth roots is the inverse of raising to the nth power. For example 2 to the power of 5 is
32. The 5th root of 32 is 2.
Math.pow(v, 1 / n); // where v is any positive real number
// and n is any positive integer
var a = 16;
var b = Math.pow(a, 1 / 2); // return the square root of 16 = 4
var c = Math.pow(a, 1 / 3); // return the cubed root of 16 = 2.5198420997897464
var d = Math.pow(a, 1 / 4); // return the 4th root of 16 = 2
Constants
Constants Description Approximate
Base of natural
Math.E 2.718
logarithm e
Natural logarithm of
Math.LN10 2.302
10
Natural logarithm of
Math.LN2 0.693
2
Base 10 logarithm of
Math.LOG10E 0.434
e
Base 2 logarithm of
Math.LOG2E 1.442
e
Pi: the ratio of circle
Math.PI circumference to 3.14
diameter (π)
Math.SQRT1_2 Square root of 1/2 0.707
Math.SQRT2 Square root of 2 1.414
https://riptutorial.com/ 26

