Number is one of the objects and is an operation to convert an argument such as a character string or a number to a Number type.
As shown below, if you pass the string “123” as an argument, it will be converted to the number 123.
Number('123') // returns the number 123 Number('123') === 123 // true Number("plantpot") // NaN Number(undefined) // NaN
If you pass a value such as “abc” as an argument, the return value “NaN” is returned because it is not a number, which means that it cannot be converted.
An object whose arguments can be parsed to get an integer.
Let’s set the number string you want to convert to the argument.
let int = parseInt("123") // 123
Although parseInt is often used like parseInt(“123”), it can be used in the following code.
For example, when dealing with integers in decimal, write as follows.