JSFiddle - React, Tailwind, and code Playground
by 533135
HTML
objects can be inherited using object.create();//internally creating a new copies and new references
<br>
where as protype copying of object points to same reference
JavaScript
var superObject = {
init: function ( carModel ) {
this.model = carModel;
},
getModel: function () {
alert(this.model);
}
};
function childObject( model ) {
function F() {};
//inherting though prototype
F.prototype = superObject;
F.prototype.internalM = function(){
alert("internal")
}
var f = new F();
f.init( model ) ;
return f;
}
var car = childObject( "tata megapixel" );
car.getModel();
car.internalM();