In a webpack environment, I have an ES6 module that defines a variable:
let my_var1 = 0
Then in the same module I have a setter function for this variable, but I would like to build it like this:
export const set_var(name, value) => {
// set "value" as new value for "name" variable of this module
}
What I want to do is reference the variable inside the module by name , so from outside, call something likeset_var('my_var1', 5)
Is there any way to access the "module" object? Something like a window object, but for a module.
source
share