ES6 - Number.parseInt()



This method parses a string argument and returns an integer of the specified radix.

Syntax

Number.parseInt(string,[ radix ])

Parameters

  • string − value to parse
  • radix − integer between 2 and 36 that represents the base.

Return value

An integer representation of the string.

Example

console.log(Number.parseInt("10"));
console.log(Number.parseInt("10.23"));

Output

10
10
Advertisements