ES6 - Number.parseInt



Parses a string argument and returns an integer of the specified radix or base.

Syntax

Given below is the syntax for the function Number.parselnt, where, string is the value to parse radix is an integer between 2 and 36 that represents the base.

Number.parseInt(string,[ radix ])

Example

<script>
   console.log(Number.parseInt('10meters'))
   console.log(Number.parseInt('abc10meters'))
</script>

The output of the above code will be as shown below −

10
NaN
Advertisements