js基础之javascript函数定义及种类-普通涵数-自执行函数-匿名函数

普通函数函数

一、不带参数

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")})
相关文章
相关标签/搜索