Classes and objects
The notion of classes and objects is fundamental to programming languages. JavaScript allows them to be used as well.
A class is used to represent any type of data. For example, people, customers, cars, and so on. We can define a class to represent each of these types of elements, for example, a Person
class to represent people, a Client
class to represent customers, and a Car
class to represent cars.
Note
Note that the class name traditionally begins with an uppercase letter.
An object, on the other hand, will be a particular element of a class (this element will be also called an instance). For example, among all the people of the class Person
, the person identified by his name “Clinton” and his first name “Bill” represents a particular object of the class Person
. This object can be associated, for example, with the variable p
in the program. We can thus create variables to identify each object associated with the class...