var userName="jack";
//根据用户名显示欢迎信息
function hello(_name){
alert("hello,"+_name);
}
//创建一个函数,用于返回一个无参数函数
function _hello(_name){
return function(){
hello(_name);
}
}
window.setTimeout(_hello(userName),3000);
真的很怪
//根据用户名显示欢迎信息
function hello(_name){
alert("hello,"+_name);
}
//创建一个函数,用于返回一个无参数函数
function _hello(_name){
return function(){
hello(_name);
}
}
window.setTimeout(_hello(userName),3000);
真的很怪
window.setInterval(_hello(userName),3000); //每隔3秒执行一次
setInterval指定运行的时间间隔,间隔到了即执行指定函数http://www.w3school.com.cn/htmldom/met_win_setinterval.asp
window.setTimeout(_hello(userName),3000);