关于闭包和this的理解
/*closure*/
??? var myObject= {
??? ? num: 2,
??? ? add: function(){
??? ??? this.num=3;
??? ??? (function(){
??? ??? ??? alert(this.num);????? // undefined
??? ??? ??? this.num=4;
??? ??? })();
??? ??? alert(this.num)?????????? // 3
??? ? }
??? }
?
??? /*this.num=3;这个this 是myObject这个对象的一个实例化。
??? 第一个alert(this.num); 中的this 是这个function(){
???? alert(this.num);
???? this.num=4;
??? }对象的一个实例化。那么第一次的alert(this.num); 当执行到它的实惠它并未被定义,所以是undefine.而第二个alert(this.num),在之前被赋值过了所以第二个值是3*/