I'm trying to export a function to use in another module, but it's one that I'm adding to the String javascript class.
How would I export the function to use in another module?
This is what I tried and it didn't work
String.prototype.trimChars = function(chars) {...}
export {String}
How do I make it so that this function is added to the string class as trimChars?
You can simply forgo the export, and import in another module. However, patching objects like this is not recommended, as it can introduce problems, if say, a browser adds a new function to String that happens to have the same name.
// in the other module
import "path/to/module.js";