2 ms·
That is because Java and C# use classical OO. Javascript does not, it uses prototypal OO. Classes are static contracts that define the state and behavior of ob
by mileycyrusXOXO 9y ago
That is because Java and C# use classical OO. Javascript does not, it uses prototypal OO.
Classes are static contracts that define the state and behavior of object instances.
Javascript objects are not contractually obligated to have the state and behavior of a 'class'.
- kowdermeister 9y agoI know that and probably that's why people feel a bit annoyed by the Class keyword. However it's really close to what classes should represent. https://en.wikipedia.org/wiki/Class_(computer_programming) https://en.wikipedia.org/wiki/Class_(computer_programming) first two paragraph matches the JS use case well. > Javascript objects are not contractually obligated to have the state and behavior of a 'class'. I don't know what you mean by "contractually obligated", but if I instantiate a class in JS then it will have a state and behavior I defined in that class. If your problem is that if I change that class later, then the instances will change as well, then yes, it works like that. Calling something a class in my mind is not strictly limited to classical OO, it's just a loose concept different languages implement differently.