In the key 'this' inside closure

I know that 'this' is different outside and inside the closure.
But why are numChildren and this.numChildren different inside closures?
Or why is numChildren the same outside and inside?

var _this:Sprite = this;
trace("[outside]this: " + this);
trace("[outside]numChildren: " + numChildren);
trace("[outside]this.numChildren: " + this.numChildren); 

(function ():void {
    trace("[inside]this: " + this);
    trace("[inside]numChildren: " + numChildren);
    trace("[inside]this.numChildren: " + this.numChildren);
    trace(_this.removeChildAt === removeChildAt);
    trace(this.removeChildAt === removeChildAt);
})();

You can see the code and output from the following link
How do you explain this?

+3
source share
1 answer

"this" . . . "this" , .

numChildren - , , , , "name" , . , "this", , .

this.name this.numChildren, , ,

+4

Source: https://habr.com/ru/post/1760454/


All Articles