Go back

JavaScript string handling - oh come on, IE!

Anyone want to guess what the result of this bit of javascript is?

<span style="color: #0000ff">var</span> myString = &quot;<span style="color: #8b0000">abc</span>&quot;;
<span style="color: #0000ff">alert</span>(myString[2]);

Let's see, shall we?

Firefox:

Google Chrome:

Safari:

IE7:

Admittedly IE8 treats strings the same way everyone has been treating them since the 1970s, but at the rate users pick up the newer versions, we're going to have to carry this around for a good many years yet.

Sigh.

Got a project? Let's work together

Compsoft is a remote working company except for Thursdays when we work together from the Alton Maltings in Alton, Hampshire (UK). Our registered address is detailed below. We'd be delighted to have either a virtual chat with you or to make arrangements to meet in person.