JavaScript is quirky but that is why I like it. Unfortunately, there is a lot of problems for amateur developers if they don't take the time to learn the language.
These solutions are transcribed from past notes on stepping over quirky pitfalls
ProperScript (ClassicScript) removes first argument and sets it as var on first line
fn (self, b, c) {
}
TO
fn (b, c) {
var self = this;
}
On instantiation, all methods must be bound to this
fn A() {
this.b = this.b.bind(this);
}
Coffeescript harder to read due to lack of parentheses and braces to distinguish sections
A note from long ago:
fn
for functionsself
as first param for all classical inheritances