Programming Tips - javaScript: How can I convert a number to hex (hexadecimal)?

Date: 2014oct13 Language: javaScript Q. javaScript: How can I convert a number to hex (hexadecimal)? A. Its built-in to the language:
const num = 255; const asHex = num.toString(16); // becomes base-16 (hex) console.log("num is " + asHex + " in hex");