JSFiddle - React, Tailwind, and code Playground
JavaScript
function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
Person.prototype.talk = function() {
return this.firstName + " " + this.lastName;
};
function Manager(firstName, lastName, accessCode) {
//shared properties
this.firstName = firstName;
this.lastName = lastName;
this.accesscode = accessCode;
}
// Manager inherits from Person
var blank = function(){};
blank.prototype = Person.prototype;
Manager.prototype = new blank();
// New manager
var manager = new Manager('jon', 'doe', 'abc123');
console.log(manager.talk());
function personChecker(person) {
var returnCode = 0;
if (person instanceof Manager) {
returnCode = 2;
} else if (person instanceof Person) {
returnCode = 1;
}
return returnCode;
}
console.log(personChecker(manager));