Using nested memory function in javascript

I kind of understand closure in javascript, but I'm not sure how it handles nested functions. For example:

var a = function(o) {
    o.someFunction(function(x) {
        // do stuff
    });
}

I know that a new closure is created every time I call a function a, but does this closure also make a new instance of the anonymous function passed to someFunction? It would be better if I did ff instead:

var b = function(x) { /* do stuff */ }
var a = function(o) {
    o.someFunction(b);
}
+3
source share
1 answer

, a, someFunction(). , , , , ( b) .

, , : . ?

+3

Source: https://habr.com/ru/post/1704634/


All Articles