JavaScript | Math.LOG2E property
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
Difference between property and function in javascript.
Property in JavaScript is nothing but a value whereas method is a function this can be understood with the help of an example given below.
<script> // car is an object. var car = {}; // car.name is a property of the given object. car.name = "Audi", // car.sayModel is a function of the given object. car.sayModel = function() { document.write("A8 <br>"); } // printing property value. document.write(car.name + '<br>'); car.sayModel(); </script> |
Output:
Audi A8
Here as we can see that property of the object car, is going to store the string as “Audi” and it can be accessed with car.name.
sayModel is a method i.e, a function of the object and it can be accessed with car.sayModel().
It can be noticed that sayModel is just a function which use ().
Syntax:
Math.LOG2E;
Parameters: Here nothing is as a parameter because of Math.LOG2E is not a function but it is a property.
Return Values: It simply return the value of base 2 logarithm of e.
Example:
Input : Math.LOG2E Output:1.4426950408889634
Explanation: Here simply value of base 2 logarithm of e is shown as ouput.
Let’s see JavaScript code for Math.LOG2E property:
<script> // Here value of Math.LOG2E is printed. document.write(Math.LOG2E); </script> |
Output:
1.4426950408889634
<script> // function is being called. function get_Value_of_base_2_lagarithm_of_e() { return Math.LOG2E; } // function is calling. document.write(get_Value_of_base_2_lagarithm_of_e()); </script> |
Output:
1.4426950408889634
<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. document.write(Math.LOG2E(12)); </script> |
Output:
Error: Math.LOG2E is not a function
Application: Whenever we need to find the value of base 2 logarithm of e that time we take the help of this property.In mathemaatics it needed a lot.
Let’s see JavaScript program on this application:
<script> // Value of Math.LOG2E is printed. document.write(Math.LOG2E); </script> |
Output:
1.4426950408889634
Supported Browsers: The browsers supported by JavaScript Math.LOG2E property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- JavaScript | undefined Property
- JavaScript | Math.PI Property
- JavaScript | Math.LN2 property
- JavaScript | multiline Property
- JavaScript | lastIndex Property
- JavaScript | Error name Property
- JavaScript | Infinity Property
- JavaScript | global Property
- JavaScript | Cursor property
- JavaScript | source Property
- How to remove CSS property using JavaScript?
- Javascript | MouseEvent which Property
- JavaScript | Array constructor Property
- JavaScript | Get the index of an object by its property.
- JavaScript | typedArray.byteOffset property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : imdev1996



