this Keyword in Different Contexts
What pattern can fix the inner function's 'this'?
const calculator = {
value: 0,
add: function(n) {
const helper = function(x) {
this.value += x;
};
helper(n);
}
};
const calculator = {
value: 0,
add: function(n) {
const helper = function(x) {
this.value += x;
};
helper(n);
}
};