Can someone explain what is wrong with this JavaScript example, and how to fix it if possible?
// I can define objects / functions like this.
window['Custom'] = function() { };
//Works...I now have a 'Custom' function in scope... I can now do this...
var c = new Custom(); // WORKS!!
//This does not seem to work!
window['Custom.prototype.msg'] = function(msg) {
alert(msg);
};
// I DO NOT WANT TO DO THIS!
Custom.prototype.msg = function(msg) { alert(msg); };
x.msg("Hello");
//FireFox Error: TypeError: x.msg is not a function...
// HOW DO I FIX THIS!?