Estoy tratando de usar la herencia prototípica y no funciona, cada vez que lo intento, sigo sin definir:
function HospitalEmployee(name) { this._name = name; this._remaningVacationDays = 20; } function Nurse() {} Nurse.prototype = Object.create(HospitalEmployee.prototype) const nurseOlynyk = new Nurse("Olynyk", ["Trauma", "Genetics"]) console.log(nurseOlynyk._remainingVacationDays) //Prints undefined¿Qué estoy haciendo mal?
Necesito usar Class y Extends para ello igual que:
class HospitalEmployee { constructor(name){ this._name = name; this._remaningVacationDays = 20; } } class Nurse extends HospitalEmployee { constructor(name, otherParams){ super(name); this.otherParams = otherParams; } } const nurseOlynyk = new Nurse("Olynyk", ["Trauma", "Genetics"]) console.log(nurseOlynyk)