Reserved Word Behavior

arrays, javascript

Solution

You're modifying `window.status` which cannot be set to an array:

https://developer.mozilla.org/en-US/docs/Web/API/Window.status

There is some unexplained behaviour in Firefox. While both `status` and `var status` at the global scope provide references to the `window.status` property, `var status` doesn't flatten the array:

status = ["meagar"];
console.log(window.status[0]); // 'm'

vs

var status = ["meagar"];
console.log(window.status[0]); // 'meagar'

Problem

While creating a small counter based game, I had an array like this: ``` var status = ["day","dusk","night","dawn"]; ``` If I tried to access the first index of the array, I would get: ``` console.log(status[0]); //yields "d" ``` @monners mentioned it might be a reserved word, so I changed the variable name to `xstatus` and it worked fine. My question is: why would `status[0]` return only the first letter of the first index?

Original source

Related problems