3 ms·
The one and only way to create JS objects
- pan69 14y agoWhat's funny about this is that these techniques where already described in 2002 in the following book: http://www.amazon.com/Object-Oriented-Programming-ActionScript-Branden-Hall/dp/0735711836/ref=sr_1_1?ie=UTF8&qid=1353631530&sr=8-1&keywords=oop+with+actionscript http://www.amazon.com/Object-Oriented-Programming-ActionScri... I'm not proud of it but I did a lot Actionscript programming in those days and I find it really interesting that these techniques are still totally valid for Javascript.
- damienklinnert 14y agoMany people tried different ways to create objects. All big frameworks come with their own methods to do this. Some people use closures to create inheritance. I just tried to define which way seems to be the best one this days to follow. I don't like to use all that frameworks for object systems. However, the most important thing is the new 'class' feature in ECMAScript6.
- beatgammit 14y agoWhy do we need this? The only thing "new" I see is returning `this` from setters, which I think is pretty lame. I've never been of the jQuery way of chaining. Also, there are several mistakes (as noted in the comments), most notably the use of Object.create, which isn't supported in IE8 and below.
- damienklinnert 14y agoThose issues are already fixed thanks to community work.
- deleted 14y ago[deleted]