function prototype javascript

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



// Only change code above this line
Dog.prototype.numLegs = 2;
let beagle = new Dog("Snoopy");function Person(name) {
  this.name = name;
}
Person.prototype.getName = function() {
  return this.name;
}

var person = new Person("John Doe");
person.getName() //"John Doe"
Source

Also in JavaScript: