let o = { f(x, y) { return x + y + this.z; }, z: 0 };
const g = o.f(?, 3);
g(1); // 4
// ...
// replace the value of `o.f`
o.f = (x, y) => x * y;
g(1); // 5 <-- isn't it expected to return 3?
isn't here g(1) expected to return 3 instead? the function o.f is changed to only multiply x and y.
or do you mean to rewrite the o.f as:
o.z = 2
o.f = function (x, y) { return x * y + this.z }
I expect that would return 5 given this is fixed as o in that case.
isn't here
g(1)
expected to return 3 instead? the functiono.f
is changed to only multiply x and y.or do you mean to rewrite the
o.f
as:I expect that would return 5 given
this
is fixed aso
in that case.