I found this while Googling for the way to convert an integer to hex in JavaScript. Not only is it basically unreadable code, but it’s stupid: this functionality is built in to the language — just pass the desired base into the toString() method:
i = 255;
i.toString(16); // 'ff'
But who am I to contradict about.com and “Stephen Chapman, your Guide To JavaScript?”
Update 2008-01-20: about.com has updated the page linked above and removed their long, obtuse code, in lieu of our friend toString()
. Keep up the good work!