JavaScript: Number.prototype.toString

By Xah Lee. Date: . Last updated: .
(number).toString()
Convert a number to string.
(number).toString(radix)
Use base radix.

To decimal (string):

console.log( (30).toString() === "30" ); // true

To binary (string):

// int to binary string
console.log( (3).toString(2) === "11" ); // true
console.log( (16).toString(2) === "10000" ); // true

To hexadecimal (string):

console.log( (15).toString(16) === "f" ); // true
console.log( (200).toString(16) === "c8" ); // true
JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

Number

prototype