function Func(x) {
???this.x = x;
???this.print=function() {
???????console.info(this.x);
???????(function (){
???????????console.info(x);
???????})();
???}
}
var a = new Func(30);
console.dir(a);
a.age = 300;
console.dir(a.print());//300,30
//存在于构造函数内的闭包 ?age:30 ?发生了闭包
//this.print 内存在闭包,闭包发生在构造new的时候,函数构造后内存销毁了,但是属性存在了.
js构造函数内存在的闭包
原文地址:https://www.cnblogs.com/C-CHERS/p/10262208.html