普通函数

1、不带参数
function fucname(){
alert("hello");
}
funcname()
2、带参数
function funcname(arg){
alert("hello");
}
funcname("Brin")

普通函数,自执行函数

1、不带参数
(function(){
alert(123);
})()
2、带参数
(function(arg){
alert(123);
})("Brin")

注:自执行函数,没有函数名结构如:     (function(){code})()

匿名函数,可以当作参数传递

//匿名函数的书写格式如下
fuction(){
alert("hello");
}
//匿名函数的应用如下
fuction facname(arg){
arg();
} //匿名函数,当成了参数传给了facname这个函数了
funcname(fuction(){alert("hello")})
05-10 20:41
查看更多