JSFiddle - React, Tailwind, and code Playground

by manoj_antony32

JavaScript

function User(name, email) {
  this.name = name;
  this.email = email;
} // this refers to object of the method, so its returns udefined

User.prototype.login = function() {
  console.log(this.email + ' logged in successfully');
}

function Admin(...args) {
  User.apply(this, args);
}

Admin.prototype = Object.create(User.prototype);

console.dir(User('mano', '[email protected]'))
var user = new User('mano', '[email protected]');
console.dir(user)
var admin = new Admin('admin', '[email protected]');
console.log(admin)
admin.login();