How to get the value of constants like PI, Eulers in javascript?
Explanation
Object: Math Variables
Math object has the following variables that give the values of
constants like PI, logarithm, Eulers, etc..
Constant
Example Code
Result
Description
E
Math.E;
Math.E returns the Eulers constant.
LN2
Math.LN2;
Math.LN2 returns the value of natural logarithm of base 2.
LN10
Math.LN10;
Math.LN10 returns the constant value of natural logarithm to the base 10.
LOG2E
Math.LOG2E;
Math.LOG2E returns the logarithmic value of E to the base 2.
LOG10E
Math.LOG10E;
Math.LOG10E returns the logarithmic value of E to the base 10.
PI
Math.PI;
Math.PI returns the value of constant PI.
SQRT1_2
Math.SQRT1_2;
Math.SQRT1_2 returns the Square Root of 0.5.
SQRT2
Math.SQRT2;
Math.SQRT2 returns the value of Square Root of 2.
Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script.
Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.