Part of Codefragment: https://hackernoon.com/object-create-in-javascript-fa8674df6ed2
var Obj = {
say: function() {
console.log('something');
}
}
var obj = Object.create(Obj);
obj.__proto__ === Obj
// true
// and a Class-Base inherit could be
//SuperType constructor function
function SuperType(firstName, lastName){
this.firstName = "Virat",
this.lastName = "Kohli"
}
//SuperType prototype
SuperType.prototype.getSuperName = function(){
return this.firstName + " " + this.lastName;
}
//SubType prototype function
function SubType(firstName, lastName, age){
//Inherit instance properties
SuperType.call(this, firstName, lastName);
this.age = age;
}
SubType.prototype = Object.create(SuperType.prototype)
//Create SubType objects
var subTypeObj1= new SubType("Virat", "Kohli", 26);
//subTypeObj1
console.log(subTypeObj1.firstName); //Output: Virat
console.log(subTypeObj1.age); //Output: 26
console.log(subTypeObj1.getSuperName()); //Output: Virat Kohli
console.log(subTypeObj1.getSubAge()); //Output: 26
console.log(subTypeObj1 instance SubType) // Output: true
console.log(subTypeObj1 instance SuperType) // Output: true