I'm rather confused at the moment, could someone explain this one to me? Maybe it's something small I'm oblivious to, but I'm confused as to why this isn't resulting as I expect it to.
I have created a samples to show the issue I'm seeing...
var dataString = "abc";
document.write(" This is a test ... " + "<br/>")
for (i in dataString ) {
document.write("<br/> +" + dataString[i] + ": ")
for (k in dataString ) {
document.write(" ="+dataString[k] +", ");
}
}
Now, my results in Chrome are:
This is a test ...
+a:
+b:
In FireFox are: (This is the result I expected)
This is a test ...
+a: =a, =b, =c,
+b: =a, =b, =c,
+c: =a, =b, =c,
Results in IE8 are:
This is a test ...
Can anyone explain to me what's happening here? Have I missed something critical?
Note:
You can translate strings to arrays across browsers using "abc".split("")
as per this example, just remember that this is no longer a string and now if you output it, it will be output as an array a,b,c