Why the window onload code doesn't work;
window.onload = function(){
var pix = 5;
alert(pix)
};
I also tried with global variable
var pix;
window.onload = function(){
pix = 5;
alert(pix);
};
The above two code doesn't alert anything
suppose i put alert outside it alerts "undefined"
I expect alert should give 5; Anybody explain what does happen here