Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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(){...}
})


That'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


Eh, 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: