Hi,
I’m developing an extension for Firefox, and for practical purpose I have modified the String prototype to add methods lacking in default JavaScript.
But these new methods are not recognized in modules.
Example:
String.prototype.myfunction = function (params) {
...
}
Then you can use this method in the current file.
"string of chars".myfunction(params)
But the prototype of String is modified only for the current file.
If you import a module with
var mymodule = require("./mymodule.js");
The code in mymodule.js can’t use these new methods for String. If I do so, it will generate an error such as:
myfunction is not a function
So, how to make modifications of the prototype String available for all imported modules?