I'm currently using JavaScript (CommonJS) in Titanium Studio and have a question about prototyping. Suppose that I want to add a new function to an existing class. For instance:
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
What is the most appropriate place where I should add this code so It became available for all classes right away?
Thanks in advance.