Created
January 15, 2020 14:51
-
-
Save adityardiansyah/b8b16bee2e51e68804a0099dc6faa843 to your computer and use it in GitHub Desktop.
Object Create ini kelebihannya adalah otomatisasi method dan mempersimpel code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Object Create | |
const methodSaya = { | |
makan: function (porsi) { | |
this.energi += porsi; | |
}, | |
main: function (jam) { | |
this.energi -= jam; | |
} | |
} | |
function Saya(nama, energi) { | |
let saya = Object.create(methodSaya); | |
saya.nama = nama; | |
saya.energi = energi; | |
return saya; | |
} | |
let aku = Saya('Aditya', 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment