The numerous overloads of 'this' is one of the things that turned me off from JS. It's great that bloggers explain the usages and how it works in different scenarios, but really the better solution would be to not have the problem at all. I would trade overloading for verbosity. An editor can easily squash the latter, where as a human has to train for the former.
Sacho|8 years ago
This may be confusing to people who expect `this` to have a certain functionality when coming from a different language, but `this` is very consistent in JavaScript. It's just not the kind of consistency people seem to expect.
There's a great way to avoid having the problem - don't use the implicit parameter! What exactly is it giving you, anyway? In almost all cases where people fail to use `this`, they essentially create a function to pass it explicitly. Why not just do that from the get go?
yarrel|8 years ago
specialist|8 years ago
The OR operator (||) is nice syntactic sugar for returning the first non-null value. Just like SQL's COALESCE.
result now equals 123.Dang it. Now I can't remember the other thing I like about JavaScript.
Oh, I do like using the shebang preamble for running nodejs scripts from the bash command line.
pwdisswordfish|8 years ago