News for hackers. Stuff that matters.
Re:OO JS in 15mins or Less by mcmire on Monday April 30, 2012 @08:28PM (#3912334)
This is okay, but you talk about "cloning" objects by giving them a different variable name, then you talk about constructors, and then you VERY briefly mention the "prototype" property -- which is actually the secret behind it all.

I feel like in any overview of JavaScript you HAVE to mention two things: 1) constructors aren't classes, they're non-magical functions (it's the "new" keyword that actually does the magic) and 2) inheritance works through a prototype chain, not through a class chain. Once you understand these two things (which will blow your mind) the rest is easy. (EDIT: okay, then there what "this" does in different contexts, but that's details)

This article is pretty elucidating: http://livingmachines.net/2009/02/creating-javascript-classe...

There are no comments on this comment yet.