Skip to content
Related Articles

Related Articles

JavaScript Math LOG2E Property

Improve Article
Save Article
  • Last Updated : 07 Nov, 2022
Improve Article
Save Article

The Math.LOG2E is a property in JavaScript which is simply used to find the value of base 2 logarithms of e, where e is an irrational and transcendental number approximately equal to 2.718 

Syntax:

Math.LOG2E;

Return Values: It simply returns the value of the base 2 logarithm of e. Below example illustrates the Math LOG2E property in JavaScript.

Below is an example of the Math LOG2E Property.

Example: 

javascript




<script>
    // Here value of Math.LOG2E is printed.
    console.log(Math.LOG2E);                   
</script>


Output:

1.4426950408889634

Example: Here simply value of base 2 logarithms of e is shown as output.

Input : Math.LOG2E
Output:1.4426950408889634

More codes for the above property are as follows: 

Program 1: Value of base 2 logarithm of e can be printed as in the form of function as shown below. 

javascript




<script>
    // function is being called.
    function get_Value_of_base_2_lagarithm_of_e()
    {
        return Math.LOG2E;
    }
     
    // function is calling.
        console.log(get_Value_of_base_2_lagarithm_of_e());
</script>


Output:

1.4426950408889634

Program 2: Here we consider Math.LOG2E as a function but in actual it is a property that is why error as output is being shown. 

javascript




<script>
    // Here we consider Math.LOG2E as a function but
    // in actual it is a property that is why error
    // as output is being shown.
    console.log(Math.LOG2E(12));
</script>


Output:

Error: Math.LOG2E is not a function

Program 3: Whenever we need to find the value of the base 2 logarithm of e that time we take the help of this property. In mathematics it needed a lot. 

javascript




<script>
    // Value of Math.LOG2E is printed.
    console.log(Math.LOG2E);
</script>


Output:

1.4426950408889634

Supported Browsers: 

  • Google Chrome 1 and above
  • Internet Explorer 3 and above
  • Edge 12 and above
  • Firefox 1 and above
  • Opera 3 and above
  • Safari 1 and above

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!