string indexers in javascript
September 22nd, 2007
Today I faced a strange bug. I was trying to get the n-th character of a JavaScript string, using the C-String notation, like this:
it worked in Firefox but caused errors on Internet Explorer. For IE to work I had to use the Java-String notation:
This one works on both Firefox and Internet Explorer.
This language is full of surprises...
ch = str[n];it worked in Firefox but caused errors on Internet Explorer. For IE to work I had to use the Java-String notation:
ch = str.charAt(n);This one works on both Firefox and Internet Explorer.
This language is full of surprises...