Skip to content

Instantly share code, notes, and snippets.

@gpDA
Last active July 8, 2020 06:34
Show Gist options
  • Save gpDA/f005b7fa20aa30808917d9f3aa177c2f to your computer and use it in GitHub Desktop.
Save gpDA/f005b7fa20aa30808917d9f3aa177c2f to your computer and use it in GitHub Desktop.
var carFactory = new VehicleFactory();
var car = carFactory.createVehicle({
vehicleType: "car",
color: "yellow",
doors: 6,
});
console.log(car instanceof Car); // true
console.log(car); // Car object of color "yellow", doors: 6 in a "brand new" state
var movingTruck = carFactory.createVehicle({
vehicleType: "truck",
state: "like new",
color: "red",
wheelSize: "small"
});
console.log(movingTruck instanceof Truck); // true
console.log(movingTruck); // Truck object of color "red", a "like new" state and a "small" wheelSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment