School is a twelve-year jail sentence where bad habits are the only curriculum truly learned.
John Taylor Gatto
New forum topics
Recent comments
- That's great news Larry. I
8 weeks 4 days ago - Worry not! IN queries are
8 weeks 6 days ago - Thank you so much! I spent 8
10 weeks 2 days ago - How to use silence post url
11 weeks 3 days ago - Thanks so much, great post.
12 weeks 3 days ago - Holy smokes, I was going
12 weeks 5 days ago - I installed this module and
13 weeks 3 days ago - Thank you very very very
14 weeks 1 day ago - Hi and thank you so
14 weeks 5 days ago - Hello and thanks in advance
17 weeks 6 days ago
Writing a simple Javascript function to create a Date object from a 'yyyy-mm-dd' string I found a small, but important, issue with the parseInt function, used to transform strings to integers.
Both parseInt('08') and parseInt('09') return zero because the function tries to determine the correct base for the numerical system used. In Javascript numbers starting with zero are considered octal and there's no 08 or 09 in octal, hence the problem.
To fix this just add the second parameter for parseInt, the base to be used for the conversion. The correct calls should be parseInt('08', 10) and parseInt('09', 10).
Another of those little details, uh?


Join the conversation
nice addition
thanks for the tip! im always using the php version for creating data object, but this is certainly handy too.
Regards,
Aislin
Good Tip.
Good Tip.
This is very good thing to
This is very good thing to catch these type of special cases. Thank you very much.
My problem has been resolved.
My problem has been resolved. Thank you very much.
why we no need of parseint
why we no need of parseint when we use "%" operator?
it executes without using parseint.
Anybody please reply.
Holy smokes, I was going
Holy smokes, I was going crazy with a deep mysterious error until I tracked it down to parseInt('08') and parseInt('09') returning zero. Thanks for the explanation and fix!