Too much Python makes Peter a shit Javascript developer

13 March 2009   0 comments   Javascript

Mind That Age!

This blog post is 9 years old! Most likely, its content is outdated. Especially if it's technical.

Powered by Fusion×

This murdered a good half hour of my time splattered with lots of alert() statements to debug. Basically, in Firefox you can do this:

var word = "Peter";
alert(word[1]); // "e" in Firefox, undefined in IE

This is the wrong way to get to character in a string in Javascript. The correct way is to use charAt() like this:

var word = "Peter";
alert(word.charAt(1)); // "e" in Firefox and IE

I don't know about the other browsers but finally now works in IE7 too. I haven't even looked at it in IE6 and don't intend to either.


Thank you for posting a comment

Your email will never ever be published

Related posts

Sandisk SSD v/s HDD 04 March 2009
Nginx vs. Squid 17 March 2009
Related by Text:
Careful when dealing with options in IE 14 April 2006
Associative arrays 21 March 2007
window.onload from before 07 June 2005
EditDistanceMatcher - NodeJS script for doing edit distance 1 matching 05 February 2011
In jQuery, using the :visible selector can be dangerous 14 September 2010