recently, when I was looking at the design pattern, I encountered a problem about closures. I can"t figure it out. Ask for help. The code is as follows:
function foo(){
var a = 10;
function bar(){
a*= 2;
return a;
}
return bar;
}
var baz = foo();
console.log(baz.toString());
var blat = foo();
console.log(blat.toString());
console.log(baz==blat)
printed result:
:
:
aaccbazblat