What is the purpose of writing "self = this"?

Hi @Chanelle,

this is a Javascript keyword which refers to the active context (object) that a method is executing in.

For example in Playcanvas scripts, inside a script method like initialize or update, this refers to the script instance. That’s why we can access properties like this.entity or this.app because those are properties of the script instance.

Here is a similar thread that explains a bit more on the subject:

1 Like