Number.toString

toString — Returns a string representation of the specified Number object.

Description

Number.toString([integer radix])

Parameters

Name Description Type Default Optional
radix A numeric value between 2 and 36 specifying the representation. integer 10 Yes

Examples

Example #1 – toString example
var n = new Number(4242); console.log(typeof n.toString()); // Will return "string". console.log(n.toString()); // Will be the primitive string "4242".
Example #2 – toString example
var n = new Number(100); console.log(n.toString(2)); // 1100100 (Binary representation) console.log(n.toString(8)); // 144 (Octal representation) console.log(n.toString(16)); // 64 (Hexadecimal representation)

External references