To create a global variable, just omit 'var' from the statement. When you omit "var", you are actually creating a variable in the window's namespace.
So zz = 1
actuallywindow.zz = 1
If you really wanted it, you could directly say
window.data = new Array();
But you can write that it's faster anyway by saying
data = ['hi','bye'];
alert(data);
Kristian
source
to share