JS: Number.prototype.toString

By Xah Lee. Date: .

Convert a number to string.

radix is the base, defaults to 10.

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

Number to string, with radix:

To Binary

// int to binary string

console.log(
(3).toString(2) === "11"
); // true

console.log(
(16).toString(2) === "10000"
); // true

To Hex

// to hex

console.log(
(15).toString(16) === "f"
); // true

console.log(
(200).toString(16) === "c8"
); // true

JS Number

  1. Format Number
  2. String to Number
  3. Random Number

Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. CSS
  3. JavaScript
  4. JS Obj Ref
  5. DOM
  6. SVG
  7. Blog