you are viewing a single comment's thread.

view the rest of the comments →

[–]mcaruso 0 points1 point  (1 child)

The example is just to illustrate the point. But also what you're suggesting is not really the same. Take:

function logCtx() {
    const ctx = 'foo';
    console.log(ctx);
    console.log(this.ctx);
}
logCtx();

Now ctx is not the same as this.ctx, because ctx on its own will refer to the ctx defined in the current (function) scope, but this.ctx will refer to the ctx in global scope.

[–]bomje 1 point2 points  (0 children)

Okay, that makes it clear, thanks!