Check out “How to Use Classes and Sleep at Night”
That’s not the same, no. There are not three scope chains — only one. Nor are there three different closure scopes — there may be many. The inner func has access to its enclosing function scope, which also has access to its enclosing function scope and so on, until it reaches the global scope. There may be many closure scopes in between. (Not limited to 3).
Yes and no. No in the sense that traditional template-based classes don’t exist in JS. The base class prototype is ultimately a working object instance that gets delegated to.
There’s a fine line between smart and “thinks it’s smarter than you.” Some languages for instance consider it a type error if you don’t wrap every function that can throw in try/catch all the way up the call stack.
The trouble with that, of course, is that if you swap out the implementation you have to make changes all the…
Everybody seems to think if I only would try their favorite type system I’d be convinced that static types reduce bug density in some significant way. You know what would convince me? Empirical evidence, but AFAIK, there isn’t any.
Scala ranks only a little better than JS in average bug density, and it’s beaten by both Ruby and clojure, which are both dynamically typed.
See “Why Composition is Immune to the Fragile Base Class Problem” in the class vs prototypal inheritance article. Most of the answers you’re after are there.
Multiple inheritance isn’t a problem in JS because it doesn’t have multiple inheritance in the same sense. It has object composition instead (via concatenation). The…