javascript总结28 :匿名函数

1 匿名函数

//匿名函数。
//    (function (){
//        console.log(1);
//    })

2  匿名函数作用

//1.直接调用
    (function (){
        console.log(1);
    })();

    //2.绑定事件
    document.onclick = function () {
        alert(1);
    };

    //3.定时器
    setInterval(function () {
        console.log(444);
    },1000);

    document.onclick = function(){
        alert(1);
    };
    
    setInterval(function(){
        alert(1);
    },1000)
原文地址:https://www.cnblogs.com/autoXingJY/p/8950390.html