JSFiddle - React, Tailwind, and code Playground
by ponmudi
HTML
<div id="1"></div>
<br/>
<div id="2"></div>
<br/>
<div id="3"></div>
JavaScript
class Animal {
constructor(type){
this.animalType = type;
}
getAnimalType(){
console.log('this.animalType: ', this.animalType );
}
}
let cat = new Animal('cat');
//by instance
document.getElementById('1').innerHTML = Object.getOwnPropertyNames(cat);
//by getting prototype from instance
document.getElementById('2').innerHTML = Object.getOwnPropertyNames(Object.getPrototypeOf(cat));
//by prototype
document.getElementById('3').innerHTML = Object.getOwnPropertyNames(Animal.prototype);