JavaScript: Number.parseInt

By Xah Lee. Date: . Last updated: .

Number.parseInt is the value of the property key "parseInt" of the Global Object.

console.log( Number.parseInt === window["parseInt"] ); // true

Syntax

Number.parseInt(string)
Convert string to a integer.
Number.parseInt(string, radix)
Use base radix.
// string to number
console.log( parseInt("324") === 324 );

Hexadecimal String to Number

Using the radix argument.

// hexadecimal string to number
console.log( parseInt("ff", 16) === 255 ); // true

Binary String to Number

// binary string to number
console.log( parseInt("101", 2) === 5 ); // true
JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

Number

prototype