Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Convert Hex to Decimal in JavaScript


const hexToDecimal = hex => parseInt(hex, 16);

const dec1 = hexToDecimal("2");
const dec2 = hexToDecimal("35");
const dec3 = hexToDecimal("1f4");
const dec4 = hexToDecimal("7b2");
const dec5 = hexToDecimal("123abc");

console.log(dec1); // 2
console.log(dec2); // 53
console.log(dec3); // 500
console.log(dec4); // 1970
console.log(dec5); // 1194684
Source by sabe.io #
 
PREVIOUS NEXT
Tagged: #Convert #Hex #Decimal #JavaScript
ADD COMMENT
Topic
Name
3+9 =