Created
December 30, 2021 19:42
-
-
Save schalkneethling/400afae5e60da0ee01d22f1d7556f1f3 to your computer and use it in GitHub Desktop.
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
// https://nationalkitty.com/cat-ancestry-where-do-cats-come-from/ | |
const pantherinae = { | |
roar: function () { | |
console.log(`${this.name} is roaring!`); | |
}, | |
domesticated: false, | |
size: "large", | |
sound: "roar", | |
}; | |
const acinonychinae = Object.create(pantherinae, { | |
roar: { value: undefined }, | |
size: { value: "medium" }, | |
sound: { value: undefined }, | |
}); | |
const felisSilvestrisCatus = Object.create(acinonychinae, { | |
purr: { | |
value: function () { | |
return `${this.name} is purring!`; | |
}, | |
}, | |
sound: { value: "purr" }, | |
}); | |
const em = Object.create(felisSilvestrisCatus, { | |
domesticated: { value: true }, | |
name: { value: "Em" }, | |
size: { value: "small" }, | |
}); | |
const cheetah = Object.create(acinonychinae); | |
const lion = Object.create(pantherinae, { | |
name: { value: "Alex" }, | |
}); | |
console.log( | |
`${em.name} is ${em.size} and can ${ | |
em.sound | |
}(${em.purr()}), but cannot roar(${em.roar}).` | |
); | |
console.log(`Is a cat domesticated? ${em.domesticated}`); | |
lion.roar(); | |
console.log(`Is a lion domesticated? ${lion.domesticated}`); | |
console.log(`Is a cheetah domesticated? ${cheetah.domesticated}`); | |
console.log(`What sound does a cheetah make? ${cheetah.sound}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment