普通函數函數
一、不帶參數
function fucname(){ alert("hello"); } funcname()
二、帶參數
function funcname(arg){ alert("hello"); } funcname("Brin")
普通函數,自執行函數spa
一、不帶參數
(function(){ alert(123); })()
二、帶參數
(function(arg){ alert(123); })("Brin")
注:自執行函數,沒有函數名結構如: (function(){code})()code
匿名函數,能夠看成參數傳遞blog
//匿名函數的書寫格式以下
fuction(){
alert("hello");
}
//匿名函數的應用以下
fuction facname(arg){ arg(); } //匿名函數,當成了參數傳給了facname這個函數了 funcname(fuction(){alert("hello")})