JSFiddle - React, Tailwind, and code Playground
by TheDiamondDoge
CSS
input[type=text] {
border: 2px solid black
}
JavaScript
function Parent(name) {
console.log(this.__proto__ === Child.prototype)
this.name = name;
}
Parent.prototype.getName = function() {
return this.name;
}
function Child(name, age) {
Parent.call(this, name);
this.age = age;
}
Child.prototype = Object.create(Parent.prototype);
Child.prototype.getAge = function() {
return this.age;
}
let parent = new Parent("Max");
let child = new Child("Dan", 12);
console.log(parent.getName());
console.log(child.getName());
console.log(child.getAge());
console.log(child.__proto__ === Child.prototype)
console.log(child.__proto__.__proto__ === Parent.prototype)
console.log(child.__proto__.__proto__.__proto__ === Object.prototype)
console.log(child.__proto__.__proto__.__proto__.__proto__ === null)
console.log(Child.__proto__ === Function.prototype)
console.log(Child.__proto__.__proto__ === Object.prototype)
console.log(Child.__proto__.__proto__.__proto__ === null)