Skip to content

Instantly share code, notes, and snippets.

@mahdiyazdani
Created September 18, 2018 20:15
Show Gist options
  • Save mahdiyazdani/9861aaf09201e642f9ffd3df59115ff9 to your computer and use it in GitHub Desktop.
Save mahdiyazdani/9861aaf09201e642f9ffd3df59115ff9 to your computer and use it in GitHub Desktop.
Class Methods in JavaScript
class Surgeon {
constructor(name, department) {
this._name = name;
this._department = department;
this._remainingVacationDays = 20;
}
get name() {
return this._name;
}
get department() {
return this._department;
}
get remainingVacationDays() {
return this._remainingVacationDays;
}
takeVacationDays(daysOff) {
return this._remainingVacationDays = this.remainingVacationDays - daysOff;
}
}
const surgeonCurry = new Surgeon( 'Curry', 'Cardiovascular' );
const surgeonDurant = new Surgeon( 'Durant', 'Orthopedics' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment