Book
Submodule 13.2: JavaScript classes
Submodule 13.2: JavaScript classes
Completion requirements
View
- Introduction to JavaScript classes
- The syntax of JavaScript classes
- Create objects with JavaScript classes
- Methods inside JavaScript classes
Introduction to JavaScript classes
Until now you have heard of classes only in the context of CSS. It is what we use to style multiple elements on a page.
However, JavaScript classes have nothing to do with style.
They introduced in the ES6 version of JavaScript and in general their role is to provide us with a more convenient syntax to create constructor functions.
Using JavaScript classes, we can encapsulate all the "characteristics" of an object inside them.
You can imagine them as the template to create multiple objects.