Whats the rule for using "this."?
I see it regularly omitted from script samples. As in:
I would script the above as:
I use it all the time. Am I using it too much?
"this" can be omitted in all contexts when accessing its properties and
methods (ie not when using it as a parameter in a function call, for
example). If you're using it incorrectly, though, you will get an error
whether you omitted it or not.
It does no harm to use it and doesn't change the speed of the script, or
anything like that. It can even make the code more readable.
This is actually the reason why it's not a good idea to create variables or
functions with identical names to those of the pre-defined objects. For
example, if you try to define a variable called "path" in the console with a
file opened in the background you'll get an error message: "redeclaration of
const path", because the Document object already has such a property
If you close the file, then you could create your variable, but it will be
overwritten as soon as a file is opened. Dangerous stuff...