Created
November 10, 2016 15:26
-
-
Save thelbouffi/c989e0240bcc24ebce1cd9a3b28cea26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vehicle = function(ty) { | |
this.type=ty; | |
} | |
vehicle.prototype.ride = function() { | |
console.log('I am riding a ', this.type); | |
} | |
var newRebuild = function(constructor){ | |
var obj = {}; | |
Object.setPrototypeOf(obj, constructor.prototype); | |
var arArgs = Array.from(arguments).slice(1); | |
constructor.apply(obj, arArgs); | |
return obj; | |
} | |
var car = newRebuild(vehicle, 'Volkswagen Caddy'); | |
//console.log(car); | |
car.ride(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment