Reputation:
Using a value in the nested (Closure like) function such as:
const f1= () => {
const a = 1;
const f2 = () => a;
return f2;
};
f2
does not have arg of a
, but returns a
of the upper-scope of f1
.
Upvotes: 0
Views: 110
Reputation: 664548
Yes.
a
is a constant and referentially transparent. It doesn't matter that f2
is a closure as long as it does not close over mutable state.
Upvotes: 2