I am trying to do something really simple – initialize an array in Javascript. And it’s not working in Google Chrome. Here is the code:
status = [];
for(i=0; i < 8; i++)
status[i]=false;
alert(status.length); //It says 0 when it should say 8
What gives?
The assignment of your
statusvariable, clashes with thewindow.statusproperty.Chrome simply refuses to make the assignment.
The
window.statusproperty, sets or gets the text in the status bar at the bottom of the browser.I would recommend you to either, rename your variable or use an anonymous function to create a new scope, also remember to always use
varfor declaring variables: