Issue
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?
Solution
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";
Answered By - Allan J. Answer Checked By - Gilberto Lyons (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.