Here you can find the source of hexToNumber()
String.prototype.hexToNumber = function(){ return Number(parseInt( this, 16 )); }; Number.prototype.toBinaryString = function( length ){ var s = Number(this).toString( 2 ); while( length && s.length < length ){ s = '0' + s; }/*from w w w .j a v a 2 s. c o m*/ return s; }; Number.prototype.toHexString = function( length ){ var s = Number(this).toString( 16 ); while( length && s.length < length ){ s = '0' + s; } return s; }; Number.prototype.truncate = function( length ){ return this & ( ~( (-1) << length ) ); };
String.prototype.hexNumber = function() { return /^(0x)?[0-9a-f]*$/i.test(this); };