What would be the output? (Different ways of Prototype calls)
@Yomesh Gupta
function Person(name) {
this.name = name;
}
Person.prototype.sayName = function () {
console.log(this.name);
}
var yomesh = new Person('yomesh');
console.log(yomesh.sayName());
console.log(Person.prototype.sayName());
console.log(Object.getPrototypeOf(yomesh).sayName());
console.log(yomesh.__proto__.sayName());
Option 1
yomesh yomesh yomesh yomesh
Option 2
yomesh undefined undefined undefined
Option 3
yomesh yomesh undefined undefined
Option 4
undefined yomesh undefined yomesh
Option 5
yomesh undefined yomesh yomesh
Option 6
undefined undefined undefined undefined