Changing the Prototype to a New Object

I don’t understand this:
How come this is easier than the regular form of creating a Prototype?

Bird.prototype = {
  numLegs: 2, 
  eat: function() {
    console.log("nom nom nom");
  },
  describe: function() {
    console.log("My name is " + this.name);
  }
};

Is this a challenge do u have a link to it?
also what is: egular form of creating a Prototype?

1 Like

@KittyKora this is the lesson: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/object-oriented-programming/change-the-prototype-to-a-new-object

How come this is easier than the regular form of creating a Prototype?
A more efficient way is to set the prototype to a new object that already contains the properties. This way, the properties are added all at once

This means that rather than making an individual propertiess like
this

Bird.prototype.numLegs = 2;
Bird.prototype.numBeeks= 2;
Bird.prototype.numWings= 2;
Bird.prototype.numPaws= 2;

It can now be done in one go.
Like a good coder we like to avoid writing double things in or code
since in the future it can get over 1000 lines of code and become, troublesome

1 Like