JS: Number.parseInt

By Xah Lee. Date: . Last updated: .


Convert string to a integer.
// string to number
console.log(parseInt("324") === 324);
Number.parseInt(string, radix)
Use base radix.
// hexadecimal string to number
console.log(parseInt("ff", 16) === 255);
// binary string to number
console.log(parseInt("101", 2) === 5);

Number.parseInt and window.parseInt

Number.parseInt is the same as the the Global Object's parseInt

Number.parseInt === globalThis.parseInt
BUY ΣJS JavaScript in Depth

JavaScript, Convert Decimal, Hexadecimal, Binary