Https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/object-oriented-programming/use-prototype-properties-to-reduce-duplicate-code

What is the point of setting .prototype properties intead o just setting it like a normal property ie. Bird.wings to Bird.prototype.wings’

function Dog(name) {
this.name = name;
}

Dog.prototype = {
// Only change code below this line

};



**Your browser information:**

User Agent is: <code>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36</code>.

**Challenge:** Change the Prototype to a New Object

**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/object-oriented-programming/change-the-prototype-to-a-new-object

It does the same thing, but using the prototype function, it will make the code a lot shorter to write, and A LOT neater when there is more to pass. Watch:

function Dog(name, age, height, weight) {
  this.name = name;
  this.age = age;
  this.height = height;
  this.weight = weight;
}

Dog.name = "Doggo";
Dog.age = "2 Dog Years";
Dog.height = "15 inches";
Dog.weight = "50kg";

Look at how unorganized and piled up that is. Now look at this:

function Dog(name, age, height, weight) {
  this.name = name;
  this.age = age;
  this.height = height;
  this.weight = weight;
}

Dog.prototype = {
  name : "Doggo",
  age : "2 Dog Years",
  height : "15 inches",
  weight : "50kg"
}

Look at how nice it looks, because it uses Object Oriented Function. That’s another difference. When you use .prototype, you use Objects, which in my opinion is cleaner than normal assignments.