In the following JavaScript code snippet, I expect that the console output be 3 but in both Chrome and Mozilla, it is 23. Why?
var status = ["Busy", "Preferred", "Available"];
console.log( status.length);
There's already a window.status (a global variable named status). Read more here.
When you're trying to set the array ["Busy", "Preferred", "Available"] to your global variable, the window.status setter will be invoked. So, window.status property will contain the string "Busy,Preferred,Available".
So, yeah change the variable name or don't use global variables (please).
window.status?window.statusgets converted into a string.windowis implicit without using.statusisn't a global variable, but a local one inside thewindow.onloadevent handler function. Hence it works.