Skip to content

Instantly share code, notes, and snippets.

@RiansyahTohamba
Created January 8, 2022 08:21
Show Gist options
  • Save RiansyahTohamba/32150595ac04f3c4d17ee41dc9f1718d to your computer and use it in GitHub Desktop.
Save RiansyahTohamba/32150595ac04f3c4d17ee41dc9f1718d to your computer and use it in GitHub Desktop.
Object Oriented Javascript
class Author{
constructor(name, year){
this.name = name;
this.year = year;
}
ieeeFormat(){
console.info(`[${this.name},${this.year}]`);
}
apaFormat(){
console.info(`(${this.name},${this.year})`);
}
// milik object bukan milik prototype
getPublications = () => {
console.info(`Looking for another ${this.name} publication`)
}
// Author.prototype.setDeadline(conference)
// ditambahkan ke prototype
setDeadline(conference) {
console.info(`Process for all Author`)
console.info(`When ${conference} is closed?`)
}
}
const hegedus = new Author("Hegedüs", 2010);
const alshayeb = new Author("Al Shayeb",2009)
console.info("List of references (in APA Format):")
hegedus.apaFormat();
alshayeb.apaFormat();
console.info("List of references (in IEEE Format):")
hegedus.ieeeFormat();
alshayeb.ieeeFormat();
alshayeb.getPublications = () => {
console.info('it was overriden here');
}
alshayeb.getPublications();
hegedus.getPublications();
hegedus.setDeadline('ICACSIS conferences');
console.log(hegedus);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment