function fun(n,o){
console.log(o);
return {
fun:function(m){//[2]
return fun(m,n);//[1]
}
}
}
var a=fun(0);
a.fun(1);
a.fun(2);
a.fun(3);
var b=fun(0).fun(1).fun(2).fun(3);
var c=fun(0).fun(1);
c.fun(2);
c.fun(3);
function _fun_(n,o){
console.log(o);
return {
fun:function(m){
return _fun_(m,n);
}
}
}
var a=_fun_(0);//undefined
a.fun(1);//0
a.fun(2);//0
a.fun(3);//0
var b=_fun_(0).fun(1).fun(2).fun(3);
//undefined,0,1,2
var c=fun(0).fun(1);//undefined,0,
c.fun(2);//1
c.fun(3); //1
var name="global";
function foo(){
console.log(name);
}
function fooOuter1(){
var name="local";
foo();
}
fooOuter1();//输出global 而不是local,并且和闭包没有任何关系
function fooOuter2(){
var name="local";
function foo(){
console.log(name);
}
foo();
}
fooOuter2();//输出local 而不是global,在函数声明是name变量作用域就在其外层函数中,嗯嗯就是闭包~
var a=_fun_(0);//undefined a.fun(1);//0 a.fun(2);//0 a.fun(3);//0
var c=fun(0).fun(1);//undefined,0, c.fun(2);//1 c.fun(3); //1
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有