Example 1 — Decimal, Binary, and Hex
Omit radix for decimal; pass 2 or 16 for other bases.
console.log((17).toString()); // "17"
console.log((6).toString(2)); // "110"
console.log((254).toString(16)); // "fe"
console.log(typeof (17).toString()); // "string" How It Works
- Default base 10.
(17).toString()is the everyday decimal string. - Binary.
6in base 2 is110. - Hex lowercase.
254becomes"fe"— letters are lowercase. - String type. The return value is always
"string".

