nested function memory usage in javascript
问题 I sort of understand closures in javascript, but what I'm not sure about is how it treats nested functions. For example: var a = function(o) { o.someFunction(function(x) { // do stuff }); } I know a new closure is created everytime I call function a , but does that closure also include a new instance of the anonymous function passed to someFunction ? Would it better if I did the ff instead: var b = function(x) { /* do stuff */ } var a = function(o) { o.someFunction(b); } 回答1: In your first