Saturday, October 16, 2021

Use Prototype Properties to Reduce Duplicate Code

 function Dog(name) {

  this.name = name;
}
Dog.prototype.numLegs = 4;


// Only change code above this line
let beagle = new Dog("Snoopy");

console.log(beagle.numLegs)
//4

No comments:

Post a Comment

JavaScript Functions as JavaScript Variables

In Javascript instead of declaring and executing a function in two different steps. for example step 1 -  function add(a,b){return a+b;} ste...