I have the following code
(function() {
var sayHello;
sayHello = (function() {
//add method to SayHello?
SayHello.load = function() {
var s = new SayHello();
return s;
};
//SayHello constructor
function SayHello() {
this.text = "hello";
}
//add method to SayHello
SayHello.prototype.print = function(selector){
var elm = document.querySelector(selector);
elm.innerHTML = this.text;
};
return SayHello;
})();
window.s = sayHello;
})();
I don't understand why the code works when assigning function to "SayHello.load" but not to "SayHello.prototype.load". And assigning function to "SayHello.prototype.print" can work but to "SayHello.print" cannot.