What is an example of how we can use a class?

Question

What is an example of how we can use a class?

Answer

You can use classes to create a template for students in a class, types of jobs, cities, musical instruments in a symphony, etc. Let’s say we want to make a class for friends you have. Then you can create instances of the Friend class and tailor the values for each individual friend:

class Friend {
		
constructor(name, location) {
			

this._name = name;
this._location = location;
	}
		
			get name() {
					return this._name;
}

get location() {
			
return this._location;
			}
	}
	
const jess = new Friend('Jess', 'New York');
const jocelyn = new Friend('Jocelyn', 'Paris');
		

const nick = new Friend('Nick', 'London');