Because obj.js is exporting an object literal. The first time you require obj.js the object is instantiated, and assigned memory allocation. Every time you require it, it's the same object, from memory. If obj.js was exporting a function that returned an abject, well that would be different.
Because
obj.js
is exporting an object literal. The first time you requireobj.js
the object is instantiated, and assigned memory allocation. Every time you require it, it's the same object, from memory. Ifobj.js
was exporting a function that returned an abject, well that would be different.Agree. But in this case the exported function will be the same for all modules (i.e. the function will not be copied for every import).
Right