As the example below, how to avoid write "this" everywhere, is there a way to write heroes, myHero,lastone
without "this
" ? Just like common javascript
When you use a class you are dealing with properties and methods, not variables and functions. That's why this
is required - it refers to the instance of a class.
You can still use local variables and functions inside class methods, but if you need to access class (instance) property or call it's methods you have to use this
.