Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Using self instead of this


Hi, I see that some users use self instead of this in their code when I watch the videos under scores such as self.attack(“zork”); However, when I try it, I get the error self is undefined. I know that I can define it by var self = this, but in the videos I watched, I did not see that used at all. Just self.attack().



Eureka! Think I solved this mystery myself. I think those other players and even the code examples given under the Goals that first load for example on “Known Enemy” is in regards to the python language! I had assumed as I was playing javaScript it was part of the language as well. I’ve just been going through this on my own by myself.



Yes, in javascript you use this, but in python it’s self.