Skip to content

Instantly share code, notes, and snippets.

@mathdroid
Last active December 22, 2020 07:32
Show Gist options
  • Save mathdroid/3ced7c5640a263952b5d43c7c56e4a4b to your computer and use it in GitHub Desktop.
Save mathdroid/3ced7c5640a263952b5d43c7c56e4a4b to your computer and use it in GitHub Desktop.
class
class Human {
constructor(arg1, arg2) {
this.name = arg1;
this.age = arg2;
}
login() {
console.log("logging in");
}
talk() {
console.log("hi there");
}
isTelkomsel() {
// return true apabila name bukan Odi
return this.name !== "Odi";
}
updateAge(newAge) {
this.age = newAge;
}
}
const odi = new Human("Odi", 5);
const amz = new Human("Amzar", 15);
const faj = new Human("Fajri", 25);
const dia = new Human("Diana", 35);
console.log(faj.isTelkomsel());
console.log(odi.isTelkomsel());
console.log(amz.age);
amz.updateAge(30);
console.log(amz.age);
// odi.walk();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment