3 ms·
I've never heard anyone, experienced or newbie, say "JavaScript has classes". People at best will say "You can sort of make classes in JavaScript using objects"
by Jare 13y ago
I've never heard anyone, experienced or newbie, say "JavaScript has classes". People at best will say "You can sort of make classes in JavaScript using objects".
To me a Class has always been "a family of objects with the same structure and behaviour, and a way to create them". Stuff like hiding, constructors, type checking, polymorphism and inheritance are interesting, but secondary details. But then, I was taught OOP using Modula-2 back in '89, so I'm used to the idea that language features and paradigm features need not match 1:1
- roel_v 13y agoYour first and second paragraph seem contradictory to me. Javascript, through what is called 'prototypes', has "a family of objects with the same structure and behaviour, and a way to create them", and varies only in implementation and semantic details from other languages. So I agree with your second paragraph and would say that JS does have classes, but then I'm not sure what your first paragraph means.
- Jare 13y agoYou can use objects and prototypes to build classes, but they are not classes by themselves. Similar to how you can use objects to create a linked list, but the language itself does not have linked lists.