Parameters or Arguments
number The variety to use in the calculation. It ought to be a fee that is higher than -1.
The log1p() characteristic returns the herbal logarithm of a range after first including 1 to the number.
If the number is -1, the log1p() function will return -Infinity.
If the range is much less than -1, the log1p() feature will return NaN.
Math is a placeholder object that incorporates mathematical functions and constants of which log1p() is one of these functions.
console.log(Math.log1p(1)); console.log(Math.log1p(2.5)); console.log(Math.log1p(-1)); console.log(Math.log1p(-1.1));
In this example, we have invoked the log1p() feature the usage of the Math class.
We have written the output of the log1p() characteristic to the internet browser console log, for demonstration purposes, to exhibit what the log1p() characteristic returns.
The following will be output to the net browser console log:
0.6931471805599453 1.252762968495368 -Infinity NaN
In this example, the first output to the console log back 0.6931471805599453 which is the herbal logarithm of two (calculation: 1+1=2 so it again the herbal logarithm of 2).
The 2nd output to the console log back 1.252762968495368 which is the natural logarithm of 3.5 (calculation: 2.5+1=3.5 so it back the natural logarithm of 3.5).
The second output to the console log returned -Infinity seeing that the quantity furnished used to be -1 (calculation: -1+1=0 so it again the herbal logarithm of 0).
The 2d output to the console log returned NaN because the quantity provided was once 0 or much less (calculation: 0+1=1 so it again the herbal logarithm of 1).