3 ms·
I would argue that Javascript has a standard way to build an object hierarchy. It's just that people find it bitter and can't help but add some syntactic sugar
by kwamenum86 17y ago
I would argue that Javascript has a standard way to build an object hierarchy. It's just that people find it bitter and can't help but add some syntactic sugar.
bitter:
myClass.prototype = new parentClass;
myClass.constructor = function(){...}
---------------------------
sweet (relatively speaking):
myClass = Class({
Extends: parentClass,
initialize: function(){...}
})
- Zef 17y agoThat's what I use. But Douglas Crockford suggests using a different way of building object hierarchies which he uses. I could ignore this, but Crockford kinda is one of _the_ Javascript guys, who, supposedly knows what he's talking about: http://javascript.crockford.com/prototypal.html http://javascript.crockford.com/prototypal.html
- kwamenum86 17y agoEh, I give Crockford all the respect in the world as one of thee js guys, but I've always found that object function downright disgusting. I am still trying to understand what advantages his prototypal toolbox has over his classical one.