Number Function in JavaScript

By Hemanta Sundaray on 2022-07-26

When used as a function, Number(value) converts a string or other value to the Number type. If the value can’t be converted, it returns NaN.

Example:

const result = Number("123")

console.log(typeof result) //number

console.log(Number("MacBook")) //NaN
console.log(Number(undefined)) //NaN

Join the Newsletter