Wondering why parseInt( “08” ) returns 0, in Javascript?

Apr 21st, 2005   9:14 pm

Well it looks like JS is defaulting to base 8 in it’s parseInt routine. There are 2 workarounds that I’ve come across (once you get over the initial reaction of what the hell use is base8 in a scripting language):

  1. use parseInt( strExpression, 10 ) .. to force decimal
  2. use Number( strExpression ) .. if you’re doing simple numerics
css.php