closure, which leads to memory leakage due to the fact that the internal variables of the parent function cannot be reclaimed by the recycling mechanism;
problem,
closure, which leads to memory leakage due to the fact that the internal variables of the parent function cannot be reclaimed by the recycling mechanism;
problem,
you should know about the garbage collection mechanism of Javascript
.
a will be recycled if there are no referenced variables, but b will not. Please refer to http://www.cnblogs.com/antine.
Previous: How to make prompt support multiple lines of text input?
Next: Font size and color setting of input placeholder under IE
first of all, there is a front-end classic closure interview question. for(var i = 0;i<5;iPP){ setTimeout(()=>{ console.log(i) },1000*i) } Everyone knows that the answer to this question is to type 5 every second. then the interviewer a...
function fn1(){ var a = 6; function fn2(){ alert(a) ; } return fn2; } var f = fn1(); f() alert 6 fn1() as in the above code, the variable f can be assigned to alert 6, but there is no response when calling fn1 directly. What is the...
function student () { var name = xxx ; var getName = function () { return name } var setName = function (newName) { name = newName; } return { getName: getName, setName: setName, name: na...
when is the closure generated? Is it when the function is defined or when it is executed? = add = ...