I'm facing an issue with my code:
function Param(){
this.name = 'sasha'
this.method = function(){
return this.name + 'native method'
}
this.pro= function(){
debugger
// Param.prototype.method() //undefined proto method bad!!
// this.__proto__.method() //undefinedproto method
Object.getPrototypeOf(this).method() //undefinedproto method
}
}
Param.prototype.method = function(){
console.log(this.name + 'proto method')
}
var param= new Param;
param.pro()
Can someone help me access the method prototype when this.name = 'sasha'
? I found a solution using
Object.getPrototypeOf(this).method.call(this);
.
Is there any other approach to achieve the same result?