> The "var fn" of course doesn't work with private member variables since you need one for each individual instance,
This makes me believe that you have no idea what you're talking about.
Normally I'd take the time to explain, but I'm pretty sure the code example right below that statement makes evident what I was getting at, and its pretty clear to me that you just aren't reading my responses, so there's really no point.
But you're probably right, I probably have no idea what I'm talking about despite having written a popular JS framework and the most widely used mobile browser on the planet.
That is just a ridiculous thing to say to Francisco Tomalsky - I think he's already demonstrated that he knows a thing or two about hacking JavaScript (see Cappuccino - http://cappuccino.org/learn/). How about you respond by giving us a code example that shows how he is wrong, rather than trolling?
2. For starters, you conveniently didn't mention how to handle private and protected member variables which is the actual interesting bit here. The goal is to not have people accidentally write into your internal data representations. This is modularization 101 and is really difficult to do with JS, since this._x = blah is accessible to EVERYONE. this._x is NOT protected in any way, every party has access to it and can change it. The "var fn" of course doesn't work with private member variables since you need one for each individual instance, you can of course do the closure trick inside your constructor:
function MyClass() { function() { var myVar = 5; this.getMyVar = function() { return myVar; } }
But this is recommended against by everyone since it 1. no longer has the benefit of modifying the prototype so its hard to inherit these methods without further trickery, and 2 is very very slow.
So no, this is not basic stuff. Not if you actually want to implement classical inheritance instead of just using names from classical inheritance and applying them to random orthogonal features.
3. Again, you run into the same super problems.
Look, I am willing to believe that people like prototypal inheritance, and I can respect the position that JS doesn't have classical inheritance because its not good or because you should use prototypal or whatever. But come on, lets not call a few hacks on top of it "classical inheritance".
Yes, I've seen Crockford's page. Its not particularly enlightening to this discussion. It presents several different forms of inherity-stuff, none of which are particularly classical in my opinion, which comes right back to the OP's original point: everyone ends up doing inheritance slightly differently and spends way too much time thinking about this problem. The fact that so much has been written on how to do inheritance in JS should be a red flag in and of itself. I will gladly take other language's "stricter less powerful" models because at least I can focus on programming and not the volumes and volumes that have been written on how to do something that should be as simple as inheriting methods.