Javascript Tips #2 : Using Mathematical Constants In Javascript

Note down following thing -

    1. The Math object allows you to perform mathematical tasks.
    2. We can access JavaScript Object and its methods to access the mathematical constants.

We can Access Following Properties

PropertyDescriptionValue(Approx)
EEuler's number2.718
LN2Natural logarithm of 20.693
LN10Natural logarithm of 102.302
LOG2EBase-2 logarithm of E1.442
LOG10EBase-10 logarithm of E0.434
PIPI3.14
SQRT1_2Square root of 1/20.707
SQRT2Square root of 21.414

Sample Program :

<script language="JavaScript">
<!--
    var radius;
    radius = 3;
    document.write(Math.PI * ((radius)*(radius)));
// -->
</script>