Since closure is a function binded to it's lexical environment I wonder why notAClosure
construction is not a closure:
let a = { b: 42 };
let notAClosure = ( param ) => { param.b++ };
let aClosure = () => { a.b++ };
notAClosure(a);
When notAClosure
called, we pass to it object a
by reference. This means that now inside closure we have access to outer scope = lexical environment.
Did I name functions right? Is aClosure
a real closure? Is notAClosure
really not a closure and if is is correct - then why?