Skip to content

Instantly share code, notes, and snippets.

@misterpoloy
Created November 27, 2020 06:36
Show Gist options
  • Save misterpoloy/98c03fc0a3f18ae43ba38969862b3973 to your computer and use it in GitHub Desktop.
Save misterpoloy/98c03fc0a3f18ae43ba38969862b3973 to your computer and use it in GitHub Desktop.
Prototype Pattern
var car = {
drive(){
console.log("Started Driving")
},
brake(){
console.log("Stopping the car")
},
numofWheels : 4
}
const car1 = Object.create(car);
car1.drive();
car1.brake();
console.log(car1.numofWheels);
const car2 = Object.create(car)
car2.drive();
car2.brake();
console.log(car2.numofWheels);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment