I have a problem understanding JavaScript context in the below snippet.
Why is the context different?
var subscribers = [];
subscribers.push(function () {
return this;
});
const subscriber = subscribers[0];
subscriber() === window // true
subscribers[0]() === subscribers // true
Please NOTE that an not asking how
this
works, as described in https://stackoverflow.com/a/3127440/3563013, but am asking why the difference in the value ofthis
for the same subscriber.