Why is the result of alert undefined but not 6?I think the function addLoadEvent works well,and so does the alert
function addLoadEvent(func){
var oldonload = window.onload;
if(typeof oldonload != 'function'){
window.onload = func;
}else{
window.onload = function(){
oldonload();
func();
}
}
}
function a(){
return 6;
}
alert(addLoadEvent(a))