Inheritance

up:: OOP Principles

Tldr

Makes properties and methods of a certain class available to a child class.

Example

User {
	user
	password
	email
 
	login(password) {
		// login logic
	}
}
 
Admin {
	user
	password
	email
	permissions
	
	login(password){
	// login logic
	}
}

An Admin also is a User. If we design code like above, that’s a lot of duplicates.

We can have a parent class (User) extend a child class (Admin). The child class can have some data inherited and additional own data.