In JavaScript, if I run the following code:
<script type="text/javascript">
var nameStr = 'Chris Kate Steve';
var names = nameStr.split(/[ ]/);
var names2 = nameStr.split(' ');
for (var i in names)
{
alert(i);
}
for (var i in names2)
{
alert(i);
}
</script>
It will alert:
0
1
2
index
input
For the first set and:
0
1
2
For the second set.
Any idea why this is?