Javascript examples for Function:Function Definition
Create new function with hierarchy
function Vehicle(){ this.wheels = true;// ww w.j a v a 2 s .co m } function Car(){ this.hasHorn = true; this.doors = 4; } Car.prototype = new Vehicle(); var coupe = new Car(); coupe.doors = 2; function create(parent){ var F = function(){}; F.prototype = parent; return new F(); } var produce = { canEat: true, tasty: true }; var apple = create(produce); apple.color = 'red'; console.log(apple.tasty); console.log(apple);