Skip to content

Instantly share code, notes, and snippets.

@thelbouffi
Created November 10, 2016 15:26
Show Gist options
  • Save thelbouffi/c989e0240bcc24ebce1cd9a3b28cea26 to your computer and use it in GitHub Desktop.
Save thelbouffi/c989e0240bcc24ebce1cd9a3b28cea26 to your computer and use it in GitHub Desktop.
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