n \{A:1, o:{B:2, F:function() {alert (O.A);//1alert (O.B);//undefined}}}o.o.f (); O={A:7, O: {a:1, o:{B:2, F:function() {alert (O.A);//7alert (O.B);//undefined}}}}o.o.o.f (); O= {//This o is added to the window closure.A:7, O: {//This o is notA:1, o:{//This o is notB:2, F:function() {alert (O.A);//7alert (O.B);//undefined}}}}o.o.o.f (); F=function(){ return{A:1, o:{B:2, F:function() {alert (O.A);//o is not defined, stating that O does not existalert (O.B);//o is not defined, stating that O does not exist}}}}f (). O.F (); F=function() {o= {A:7,b:8} return{A:1, o:{B:2, F:function() {alert (O.A);//7alert (O.B);//8 return is not in the closure .}}}}f (). O.F (); F=function() {o= {//This o is added to the function closure.A:1, o:{//This o is notB:2, F:function() {alert (O.A);//1alert (O.B);//undefined } } } returno;} F (). O.F (); F=function(){ return{A:1, o:{B:2, F:function() {o= {A:3,b:4} alert (O.A);//3alert (O.B);//4}}}}f (). O.F (); F=function() {o= {A:5,b:6} return function() {a=1, O={b:2, F:function() {alert (O.A);//unudefined The function as the closure level, one layer of the upward search, found it will not findalert (O.B);//2 } } returno; }}f () (). f (); F=function() {o= {A:5,b:6} return function() {a=1, b={b:2, F:function() {alert (O.A);//5alert (O.B);//6 } } returnb; }}f () (). f ();
f =function(){ return function() {o= {A:15,b:16}//Add to ClosuresA=1, b={//Add to ClosuresO:{a:11,b:12},//did not add to the closure packageB:2, F:function() {alert (O.A);// thealert (O.B);// - } } returnb; }}f () (). f ();
Jquery10 Closure Example