この JavaScript の例の何が問題なのか、可能であれば修正する方法を誰か説明できますか?
// 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!?