So in my javascript I have the following code:
var wholeHash = window.location.hash.substring(1);
var data = new Object();
// Remove the bang or slash if one appears at the beginning
if (wholeHash[0] == '!') { wholeHash = wholeHash.substring(1); }
if (wholeHash[0] == '/') { wholeHash = wholeHash.substring(1); }
When this is about to run, wholeHash has a value of "/search/&&stype=quick". However, wholeHash[0] returns nothing, which causes wholeHash[0] == '!' to be false. This is only the case in IE.
Why is this? I am aware I can instead use startswith but I am generally interested why IE cannot get individual characters of a string while the other browsers can.
Because indexing into strings with array style indexing is new, and older versions of IE lack this. Instead you will need to use
mystring.charAt(0)if you need to support IE’s before 8.