Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

javascript
math
logarithm
communitycreator

What is Math.log10() in JavaScript?

Arslan Bajwa

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Math is a built-in object in JavaScript that contains different methods and properties used to perform mathematical operations. It contains the log10() function, which is used to compute the base 10 logarithm of a specified number.

Syntax

Math.log10(param);

Parameter

  • param: This is the input value of type Number for which we want to find the log10().

Number in JavaScript is a 64-bit double-precision value that is the same as double in C# or Java.

Return value

  • Number: It returns the base 10 logarithm of the input parameter param. It is of type Number.

  • -Infinity: The function returns this if the input parameter param = 0.

  • +Infinity: The function returns this if the input parameter param = +Infinity.

  • NaN: The function returns this if the input parameter param < 0 or param = -Infinity.

Example

console.log("log10(-1) = " + Math.log10(-1));
console.log("log10(0) = " + Math.log10(0));
console.log("log10(1) = " + Math.log10(1));
console.log("log10(20) = " + Math.log10(20));
console.log("log10(∞) = " + Math.log10(Infinity));
console.log("log10(-∞) = " + Math.log10(-Infinity));

RELATED TAGS

javascript
math
logarithm
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring