Not really creating a class?

In the challenge " Use class Syntax to Define a Constructor Function", module ES6 of the program " JavaScript Algorithms and Data Structures" it says:

" It should be noted that the class syntax is just syntax, and not a full-fledged class-based implementation of an object-oriented paradigm, unlike in languages such as Java, Python, Ruby, etc. "

Does it means that we’re not really creating a class? I solved the exercise and console.log(typeof(Vegetable)) returned me a function, so I wonder that it might have something to do with this statement.

It’s not Java, this is what this quote means.

I’ve always just kinda taken this as given (JS classes aren’t real classes!), and it gets repeated a lot. But I don’t think that actually means anything except “JavaScript is not Java”.

Particularly because this bit doesn’t seem to be true:

It’s actually very similar in above two languages. Slightly different mechanism (inheritance comes via prototypes), works very much the same though. It’s “just syntax” there are well, although “just syntax” doesn’t really mean anything (class is syntactic sugar for constructor functions + functions defined on them + their prototype…which is how you create types of objects with attached methods in JS…which is what classes do…)

A class is a template for creating objects of a specific type. That’s what classes in JS do.

The only thing I know in this context about Python is, that in Python technically EVERYTHING is an class-object. Even a simple integer number is an object under the hood, hence even while holding the value 0, it’s like 6 Byte or so in memory, because of all the class-attributes and methods it inherited.

Every Python file and programm is also an class objects under the hood, which you wouldn’t notice until you use some advanced developement functionality.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.