Classes in JavaScript query

(Jude Gibbons) #1

I’ve just been reading this article, and the first section about “classes” in JavaScript is kinda going over my head. Does anyone have an opinion about it and could someone explain a bit more about what he’s talking about?* (I know that “JavaScript does not have classes” so it’s a bit confusing…)

* I realise that I’m lighting the blue touch paper here! *stands back*

(Michael Brett) #2

Hi Judes, that’s a good article, and admittedly a very opinionated one.

I would really advise you to read this & Object Prototypes from the You Don’t Know JS series for more information on how JavaScript handles inheritance (or doesn’t really, as it turns out).

In particular, pay attention to what the author refers to as Objects Linked to Other Objects (OLOO), because it’s a great explanation of how delegation works through the prototype chain.

Rather than sum it up by paraphrasing here, I really think you will get the most out of reading the book (you can read it online).

(Jude Gibbons) #3

Thanks - I have a couple of his other books in my virtual ‘to read’ pile so will add that to it!

(Stuart Langridge) #4

You may also find useful reading for some of this stuff, although Crockford’s style is pretty sparse.

(Michael Brett) #5

I like Crockford (especially on video) but the thing that I struggle with in Crockford’s ‘JavaScript - The Good Parts’ is the use of railroad diagrams. I know that these are meant to be simple to follow, but for me they are a lot of work. Are railroad diagrams a Computer Science thing?

(Alastair McGowan-Douglas) #6

Don’t confuse class in the programming sense (definition of a data structure) with class in the HTML sense (label applied to structural elements for taxonomical purposes).