It’s not going to be a rant as title might suggest you. I’ve been reading a book about Phonegap (now known as Apache Cordova), and came across a cool remark in the text:
nuts, so it’s always better to refer to a variable that we know
will always refer to the object.
I smiled. This remark was referring to a simple code that had this assignment:
self = this
I’ve learned about JS “this” the hard way. Indeed, it’s not intuitive and goes against what developer learned from other languages. Anyway, I thought I know how it works well… until I read this quote. I went back online to refresh my knowledge, just to learn the damn thing again. 🙂 Anyway, in case if you’re in the same boat, old friend MDN (Mozilla Developer Network) is your friend. That’s the best article about “this” scope, strict and non-strict mode (who came up with these names!?), syntax for event handlers etc.