Number parseInt() method

Find all information about the JavaScript parseInt() method of the Number object

Parse the parameter as an integer and return:

Number.parseInt('10') //10
Number.parseInt('10.00') //10
Number.parseInt('237,21') //237
Number.parseInt('237.21') //237
Number.parseInt('12 34 56') //12
Number.parseInt(' 36 ') //36
Number.parseInt('36 is my age') //36

as you can seeNumber.parseInt()Very flexible. It can also convert strings with words toFirstNumber, but the string must start with a number:

Number.parseInt('I am Flavio and I am 36') //NaN

You can add a second parameter to specify the base. Radix 10 is the default value, but you can also use octal or hexadecimal number conversion:

Number.parseInt('10', 10) //10
Number.parseInt('010') //10
Number.parseInt('010', 8) //8
Number.parseInt('10', 8) //8
Number.parseInt('10', 16) //16

Download mine for freeJavaScript beginner's manual

More js tutorials: