Boris Yeltz Boris Yeltz - 2 months ago 17
Javascript Question

Where can I find an example of a large JavaScript project using Crockford's method for prototypal inheritance?

I have read about Crockford's push for using JavaScript in a more obviously prototypal manner (cloning objects to create new ones, never using the "new" keyword). But in the wild, I have never seen anybody use this style for larger projects.

Where can I find examples of a large project that uses this style?


Have to offer an anti-awnser ;) though like to see big projects using it as well (if there are any). I love Object.create myself and prefer it, though I've never been able to use it widely in a big project nor feel it should be.

  1. OO Developers are addicted to the 'new' operator, it's a hard habbit to get rid off and easy to understand at a glance. Code written in a classical way is right now easier to hand over to the next dev, which already is a strong arguement against Object.create.

  2. Object.create in ES5 (the next JS version) is immensly more powerful and drastically different from Object.create as a shim in ES3 (current JS version). For this reason it's better to avoid Object.create (as is available right now) as a widely used strategy in big projects as it will work differently when ES5 becomes mainstream than is implementable right now.

  3. Big projects make use of frameworks (when you don't have rogue JS 'ninjas' who insist on writing everything from scratch reinventing the wheel over and over again) and all popular frameworks promote prototypical inheritance the classical way. They might have an Object.create method somehwere in the form of .clone() or something, but it's obscured from the tutorials and documentation in respect to object inheritance and subclassing.

  4. Private properties are impossible with Object.create in ES3. I came across more issues the more I fiddled around with Object.create and boy have I fiddled around with it...

I've played around a lot with Object.create and even written a tiny framework around it called 'Objection' (if yer interrested, you'll find it ;) though refraining from linking to github) and 'JSoo' (discontinued). It's just too zany, unfinished and progressive to become mainstream and maintainable in terms of human resources for big projects. I recommend against it whilst being a supporter.