I am trying to use Object.Create in JavaScript. I currently have the following code:
var vehicle = { getModel: function () { console.log( "The model of this vehicle is.." + this.model ); } }; var car = Object.create(vehicle, { "id": { value: 9, }, "model": { value: "Ford", } }); var van = Object.create(vehicle, { "id": { value: 10, }, "model": { value: "Big Van", enumerable: true }, "make": { value: "Warrior", }, "getMake": function () { console.log( "The make of this vehicle is.." + this.make ); } });
I tried adding a function to van for getMake, but getting an error:
TypeError: property 'getMake' of object # is not a function when called:
van.getMake ();
Is it possible? How do you do this?
source share