because the counter variable that we imported is a disconnected copy of the counter variable from the module.
JavaScript Modules: A Beginner’s Guide
Preethi Kasireddy
1.5K76
I disagree. Or the example is unclear.
It seems the counter was not incremented because when you did { counter: counter, …} , counter being a primitive type.. there was a copy by value.
This would not be the case if the var counter is an object and { counter: …} is getting a reference of the object.
then when you .increment(), the original value should change.