JavaScript Math log() method18 Mar 2025 | 1 min read The JavaScript math log() method returns the natural logarithm of the given number i.e. base e. If the number is negative, it returns NaN. SyntaxThe log() method is represented by the following syntax: Parameternum - A number. ReturnThe natural logarithm of a number. JavaScript Math log() method exampleHere, we will understand log() method through various examples. Example 1Let's see an example to print the natural logarithm of a number. Output: 0 1.6094379124341003 2.302585092994046 Example 2Let's see the result of log() method in different test cases. Output: NaN NaN -Infinity Example 3Here, you can test log() method with your own test cases. Next TopicJavaScript Math |
JavaScript The JavaScript math exp() method returns the exponential form of the given number i.e. ex. Here, x is the argument and e is the base of natural algorithms. Syntax The exp() method is represented by the following syntax: Math.exp(num) Parameter num - A number. Return The number in the form of...
1 min read
JavaScript The JavaScript math hypot() method returns the square root of sum of the squares of given numbers. It returns NaN, if any argument cannot be converted to a number. Syntax The hypot() method is represented by the following syntax: Math.hypot([num1[, num2[, ...]]]) Parameter Num - A number. Return The square root...
1 min read
JavaScript The JavaScript math cos() method returns the cosine of the given number. The value returned by cos() method ranges -1 to 1, which represents the cosine of the angle. Syntax The cos() method is represented by the following syntax: Math.cos(num) Parameter num - A number. Return The cosine of a number. JavaScript...
1 min read
JavaScript The JavaScript math sqrt() method returns the square root of a number. If the provided number is negative, it returns NaN. Syntax The sqrt() method is represented by the following syntax: Math.sqrt(num) Parameter num - A number. Return The square root of the given number. JavaScript example Here, we will understand sqrt()...
1 min read
JavaScript The JavaScript math pow() method returns the base to the exponent power such as baseexponent. In other words, the base value (x) is multiplied with itself exponent times (y). Syntax The pow() method is represented by the following syntax: Math.pow(base,exponent) Parameter Base - The base number. Exponent - The number...
1 min read
JavaScript The JavaScript math cbrt() method returns the cube root of the given number. Unlike sqrt() method, this method accepts negative number. Syntax The cbrt() method is represented by the following syntax: Math.cbrt(num) Parameter num - A number. Return The cube root of the given number. JavaScript example Here, we will understand cbrt()...
1 min read
JavaScript The JavaScript math sinh() method returns the hyperbolic sine of the given number. Syntax The sinh() method is represented by the following syntax: Math.sinh(num) Parameter num - A number. Return The hyperbolic sine of a number. JavaScript example Here, we will understand sinh() method through various examples. Example 1 Let's see a simple example...
1 min read
JavaScript The JavaScript math sin() method returns the sine of the given number. The value returned by sin() method ranges between -1 to 1, which represents the sine of the angle. Syntax The sin() method is represented by the following syntax: Math.sin(num) Parameter num - A number. Return The sine of the...
1 min read
JavaScript The JavaScript math random() method returns the random number between 0 (inclusive) and 1 (exclusive). Syntax The random() method is represented by the following syntax: Math.random() Return The random number between 0 (inclusive) and 1 (exclusive). JavaScript example Here, we will understand random() method through various examples. Example 1 Let's see an...
1 min read
JavaScript The JavaScript math floor() method decreases the given number up to the closest integer value and returns it. If the given number is already an integer, the floor() method returns it directly. Syntax The floor() method is represented by the following syntax: Math.floor(num) Parameter num - A number. Return A largest...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India