And this is why I hate JavaScript...

Because stuff that works in some browsers, eg Firefox and Safari:

a = '123';
b = a[1]; // b is now '2', or undefined, take your pick...

...does NOT work in Internet Explorer. If you run the code above you'll find that b ends up "undefined" in IE.

OK, so the "correct" code is pretty straightforward: use the charAt() function, or substr(), or one of a number of other solutions. But if you're constantly working in other languages (eg. PHP) and just happen to have a need to write some quick JavaScript, it is extremely frustrating when you (A) use a language construct that works in so many other languages, (B) find that it works fine in your development environment and then (C) find that it doesn't actually work fine when you test it in other environments. Grrrrr!

That's my vent for the day. Back to work now...

EDITED TO ADD: And who the hell decided it would be a good idea to number months from 0-11 in JavaScript Date objects? Am I the only one that thinks that's a DUMB idea? Days of the month are numbered 1-31. If some numbskull decided months should be numbered starting at 0, then why wasn't that same rationale at least applied consistently to the day of the month? Not that I would want that, of course, I'm just saying...

photo

jtfjfjjfjf jujjj

very nice blog

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.
By submitting this form, you accept the Mollom privacy policy.