I have the following snippet of javascript code which is acting in a rather odd way
var firstNewLine = content.indexOf('\n');if(firstNewLine == -1){ return {description : content};} var typeString = content.substring(0, firstNewLine);typeString = typeString.toLowerCase()//other stuffif(imageDict[typeString] == undefined){ //other stuff}
In a particular run typeString ends up getting set to "bar" when I then index imageDict using this I get undefined. This is odd as when using the Chrome debugger if I place a breakpoint on the second if statement it shows that imageDict does indeed have a defined entry for "bar". If I put imageDict["bar"] into the watch expressions then I get the result I expect (A path to an image file) however if I add a watch expression for imageDict[typeString] I get undefined. So when the code actually runs the expression in the second if statement evaluates to true.
So it appears I have two strings "bar" and "bar" which are visually identical in their representation in the chrome debugger but javascript considers different. Can anyone shed any light on what might be happening?<br><br>Note that this code works fine in other instances, it's just this one particular case.