JS中性感的箭头函数 ()=>{}

(参数)=>{根据参数DoSomething}

1.有没有返回值(有传入参数必有()=>)

(1)没有返回值:
    setTimeout(    function (message) {alert(message);}    ,1000)
----------------
    setTimeout(    (message) => alert(message)             , 1000)

(1)有返回值:
    var p= function (a) {return a+1;}
----------------
    var p= (a)=>a+1;或var p= (a)=>{a+1}

this绑定

posted @ 2020-07-21 15:34  姜佳泉  阅读(817)  评论(0编辑  收藏  举报