javascript中立即执行函数
直接po图和代码
//-------------------
//立即执行函数(第1种写法)
(function(){
//立即执行函数中的this指的是window对象
console.log("立即执行函数中的this=" + this);
console.log(this.aaa); //结果是undefined
console.log(this.bbb); //结果是undefined
})();
//立即执行函数(第2种写法)
(function(){
//立即执行函数中的this指的是window对象
console.log("立即执行函数中的this是" + this);
console.log(this.yyy); //结果是undefined
console.log(this.zzz); //结果是undefined
}());