JSFiddle - React, Tailwind, and code Playground

by TheDiamondDoge

JavaScript

function Person(name) {
  console.log(this.getName())
  this.name = name;
  console.log(this.getName())
  console.log(this.__proto__ === Student.prototype)
}

Person.prototype.getName = function() {
  return this.name
};

function Student(name, age) {
  Person.call(this, name);
  this.age = age;
}

Student.prototype = Object.create(Person.prototype);

const s = new Student("Max", 30);
console.log(s.__proto__ === Student.prototype)
console.log(Student.prototype.__proto__ === Person.prototype);
console.log(Student.__proto__.__proto__ === Object.prototype);