locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
12 lines (11 loc) • 394 B
JavaScript
export function hexdec(hexString) {
// discuss at: https://locutus.io/php/hexdec/
// parity verified: PHP 8.3
// original by: Philippe Baumann
// example 1: hexdec('that')
// returns 1: 10
// example 2: hexdec('a0')
// returns 2: 160
hexString = (hexString + '').replace(/[^a-f0-9]/gi, '');
return parseInt(hexString, 16);
}