How to call a function using object prototype in Javascript -


i had doubt.is possible call 1 function/method present inside 1 class using object prototype in javascript ? if possible can make below code correct.

(function(){     window.peer=function(){         var peer=this;         peer.getmessage=function(){             alert("hello!!! site.")         }     } })();   <button type="button" id="btn">click here</button> <script> document.getelementbyid('btn').onclick=function(){     peer.prototype.getmessage(); } 

the above code throwing error.please give me idea resolve this.

(function(){     window.peer=function(){}     window.peer.prototype.getmessage=function(){         alert("hello!!! site.")     } })(); <button type="button" id="btn">click here</button> document.getelementbyid('btn').onclick=function(){     var peer = new peer();     peer.getmessage(); } 

you can treat peer object


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -