We now have a youtube channel. Subscribe!

Learn how to implement the various JavaScript Math Properties in this step by step guide



Hello guys! welcome to my new tutorial post on JavaScript. In my previous tutorial, i discussed about the complete guide to JavaScript Math Object with examples and i listed out the properties and methods of the object without any proper example.

So am going to be using proper examples to illustrate how to implement the JavaScript Math properties in this tutorial. Read through very well and ask your questions where necessary. I will be starting this tutorial with the JavaScript Math E property.

Math E Property

This is an Euler's constant and also the base of natural logarithms, approximately  2.718.

Syntax

Its syntax is as follows -

Math.E

Example

Try the following example below.

<html>
     <head>
          <title> JavaScript Math E Property</title>
     </head>

     <body>
          <script  type = "text/javascript">
               var  property_value =  Math.E
               document.write("Property Value is :  "  +  property_value );          
          </script>
     </body>
</html>

Output

Below is the output of the above example.


You can also read our tutorial post on: What is JavaScript?


The Math LN2 Property

It returns the natural logarithm of 2, which is approximately 0.693.

Syntax

Its syntax is as follows -

Math.LN2

Example

Try the following example below.

<html>
     <head>
          <title> JavaScript Math LN2 Property</title>
     </head>

     <body>
          <script  type = "text/javascript">
               var  property_value =  Math.LN2
               document.write("Property Value is :  "  +  property_value );          
          </script>
     </body>
</html>

Output

Below is the output of the above example.


The Math LN10 Property

It returns the natural logarithm of 10, which is approximately 2.302.

Syntax

Its syntax is as follows -

Math.LN10

Example

Try the following example below.

<html>
     <head>
          <title> JavaScript Math LN10 Property</title>
     </head>

     <body>
          <script  type = "text/javascript">
               var  property_value =  Math.LN10
               document.write("Property Value is :  "  +  property_value );          
          </script>
     </body>
</html>

Output

Below is the output of the above example.


You can also read our tutorial post on: How to implement JavaScript functions in your program

The Math LOG2E Property

It returns the base 2 logarithm of E, which is approximately 1.442.

Syntax

Its syntax is as follows -

Math.LOG2E

Example

Try the following example below.

<html>
     <head>
          <title> JavaScript Math LOG2E Property</title>
     </head>

     <body>
          <script  type = "text/javascript">
               var  property_value =  Math.LOG2E
               document.write("Property Value is :  "  +  property_value );          
          </script>
     </body>
</html>

Output

Below is the output of the above example.



The Math LOG10E Property

It returns the base 10 logarithm of E, which is approximately 0.434.

Syntax

Its syntax is as follows -

Math.LOG10E

Example

Try the following example below.

<html>
     <head>
          <title> JavaScript Math LOG10E Property</title>
     </head>

     <body>
          <script  type = "text/javascript">
               var  property_value =  Math.LOG10E
               document.write("Property Value is :  "  +  property_value );          
          </script>
     </body>
</html>

Output

Below is the output of the above example.


You can also read our tutorial post on: Python on OX

The Math PI Property

The JavaScript Math PI returns the ratio of the circumference of a circle to its diameter (width) which is approximately 3.14159.

Syntax

Its syntax is as follows -

Math.PI

Example

Try the following example below.

<html>
     <head>
          <title> JavaScript Math PI Property</title>
     </head>

     <body>
          <script  type = "text/javascript">
               var  property_value =  Math.PI
               document.write("Property Value is :  "  +  property_value );          
          </script>
     </body>
</html>

Output

Below is the output of the above example.


The Math SQRT1_2 Property

It returns the square root of 1/2; equivalently, 1 over the square root of 2 which is approximately 0.707.

Syntax

Its syntax is as follows -

Math.SQRT1_2

Example

Try the following example below.

<html>
     <head>
          <title> JavaScript Math SQRT1_2 Property</title>
     </head>

     <body>
          <script  type = "text/javascript">
               var  property_value =  Math.SQRT1_2
               document.write("Property Value is :  "  +  property_value );          
          </script>
     </body>
</html>

Output

Below is the output of the above example.



The Math SQRT2 Property

The Math SQRT2 returns the square root of 2, which is approximately 1.414.

Syntax

Its syntax is as follows -

Math.SQRT2

Example

Try the following example below.

<html>
     <head>
          <title> JavaScript Math SQRT2 Property</title>
     </head>

     <body>
          <script  type = "text/javascript">
               var  property_value =  Math.SQRT2
               document.write("Property Value is :  "  +  property_value );          
          </script>
     </body>
</html>

Output

Below is the output of the above example.


Alright guys we have come to the end of this tutorial. In my next tutorial, i will be making use of few examples to demonstrate the JavaScript Math methods.

Thanks for reading and bye for now.

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.
© 2023 ‧ WebDesignTutorialz. All rights reserved. Developed by Jago Desain