prototype check in js code example
Example 1: isPrototypeOf js
/"Checks if an object exists in another object's prototype chain."/
function Bird(name) {
this.name = name;
}
let duck = new Bird("Donald");
Bird.prototype.isPrototypeOf(duck);
// returns true
Example 2: function prototype javascript
function Person(name) {
this.name = name;
}
Person.prototype.getName = function() {
return this.name;
}
var person = new Person("John Doe");
person.getName() //"John Doe"