JavaScript toString() Method with Radix

A small JavaScript detail, but a surprisingly powerful one 💡 Most of us use: num.toString() to convert a number into a string. What’s less commonly discussed is that toString() also accepts a radix (base), which allows the same number to be represented in different numeral systems : num.toString(2) // Binary num.toString(8) // Octal num.toString(16) // Hexadecimal For example: let num = 9; num.toString(2); // "1001" This single method becomes extremely useful when working with: Bit manipulation and binary logic ⚙️ Performance-oriented problem solving A good reminder that many “advanced” solutions are built on a strong understanding of fundamentals. #JavaScript #SoftwareEngineering #ProblemSolving #ContinuousLearning

To view or add a comment, sign in

Explore content categories