Skip to content

Instantly share code, notes, and snippets.

@Bouzazi
Last active June 27, 2019 10:20
Show Gist options
  • Save Bouzazi/e73fc900ccd82eddf7915a0afe9b46fc to your computer and use it in GitHub Desktop.
Save Bouzazi/e73fc900ccd82eddf7915a0afe9b46fc to your computer and use it in GitHub Desktop.
// Execute using --use_strict tag "node --use_strict classes.js"
class Human {
constructor(name, job, skills = []){
this.name = name;
this.job = job;
this.skills = skills;
}
getJob(){
return this.job;
}
setJob(newJob){
this.job = newJob;
}
leaveJob(){
this.job = "unemployed";
}
learnNewSkill(newSkill){
this.skills.push(newSkill);
}
forgetSkill(skill){
this.skills = this.skills.filter(element => element !== skill);
}
}
class Student extends Human {
constructor(){
super();
}
}
let human = new Human("Amine", "Freelancer", ["Android", "Web", "SysAdmin"]);
let me = new Student();
// setJob to set a Job | getJob to get a Job
me.setJob("Web developer");
me.learnNewSkill("React");
me.forgetSkill("React");
me.leaveJob();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment