Primitive types

  1. number
  2. string
  3. boolean

Complex types

  1. Objects
  2. Arrays

Classes

In JavaScript, classes are a way to define blueprints for creating objects (these objects are different from the objects defined in the last section).

For example

class Rectangle {
   constructor(width, height, color) {
	    this.width = width;
	    this.height = height;
	    this.color = color; 
   }
   
   area() {
	   const area = this.width * this.height;
		 return area;
   }
   
   paint() {
			console.log(`Painting with color ${this.color}`);
   }
   
}

const rect = new Rectangle(2, 4)
const area = rect.area();
console.log(area)

Key Concepts

  1. Class Declaration:
  2. Constructor:
  3. Methods:
  4. Inheritance:
  5. Static Methods:
  6. Getters and Setters: