Use Prototype Properties to Reduce Duplicate Code - How it reduces Duplicate Code?

Tell us what’s happening:
Consider the below approaches,

function Dog(name) {
this.name = name;
}
Dog.prototype.numLegs = 2;

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

How approach 1 will help to reduce duplicate code versus approach 2?
Why are we using prototype instead of defining it inside constructor function?

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/use-prototype-properties-to-reduce-duplicate-code

#2 creates a place in memory that stores a number 2 with the name numLegs for every Dog object created. Create 1000 Dogs then 1000 places in memory storing a number 2

#1 creates one place in memory that stores a number 2 with a name numLegs that all Dogs created share whether you make 1 or 1000.