Does a parameter variable create closure in JavaScript? -
i tasked trace cause of memory leak in 1 of our applications i'm trying study closures. wonder if code creates closure:
function foo(p) { return function(){ return p + 1; } }
based on understanding, closure created when inner function gains access local variable of parent function. parameter p
local foo
, if inner function gains access p
, mean closure created?
the parameters of function exists in local scope of function, yes creates closure
Comments
Post a Comment