1.
functionsay667(){
varnum=666;
varsayAlert=function(){alert(num);}
num ;
returnsayAlert;
}
varsayAlert=say667();
sayAlert();
2.
functionsetUpSomeGlobals(){
varnum=666;
gAlertNumber=function(){alert(num);🎜>gIncreaseNumber=function(){num ;🎜>gSetNumber=function(x){num=x; 🎜>}
setUpSomeGlobals();//Weisen Sie drei globalen Variablen Werte zu
gAlertNumber();//666gIncreaseNumber();
gAlertNumber();//667
gSetNumber(12 );
gAlertNumber();//12
3.
varalice='HelloAlice';
returnsayAlert;
}
varhelloAlice=sayAlice();
helloAlice();//HelloAlice
5.
varanArray=[1,2,3];
varref=someRef;
returnfunction(x){
num =x;
anArray. push(num );
alert('num:' num 'nanArray' anArray.toString() 'nref.someVar' ref.someVar);
}
}
closure1=newClosure(40,{someVar:'closure1'});
closure2=newClosure(1000,{someVar:'closure2'});
Abschluss1(5);
Abschluss2(-10);