Math.log() Method - Math Functions
Math.log() method of Math Functions in Javascript.
How to get the logarithm value of a number in javascript?
Explanation
Object:
MathMethod:
Math.log()Description:To get the logarithm value of a number we use this function. The below example will get the logarithm value for 0, 2, 1 using Math Functions.
Example:
<script type="text/javascript">
document.write('Log of 4 is::'+Math.ceil(Math.log(4))+ "<br/>");
document.write('Log of 0 is::'+Math.log(0) + "<br/>");
document.write('Log of 1 is::'+Math.log(1));
</script>
Result:
In the above example,
- The logarithm value for "1" found using "Math.log()" function is "0".
- Logarithm value of "0" returns a "infinity" value.
- The logarithm value of "4" is "1.3862".
- Math.ceil()function ceils the result "2".