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

普通函数

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")})
塑造ing
原文地址:https://www.cnblogs.com/Brin-guo/p/7251718.html