difference between export and module.export in sea.js

difference between export and module.export in sea.js

Today I am trying to use sea.js to build a tiny webApp, I found some other webApp was built by sea.js.I just do not understand the difference between export and module.export. After read this. I understand the difference.

export and module.export are two pointers point to a same area in memory, we called it objectA.We can use export.xxx=... and module.export[]=... to add some new function and attributes to objectA. However, if we use something like thisexport = {x:1,y:2} or module.export = function() {}, what do we really have done? We just ask for a new area of memory and point the export and module.export to this new area. If we do not point the two pointer to the same object, things become terrible. That's why when we do something likemodule.export={a:b,c:d} we must do this export = dodule.export. The most easy understanding way is :Just remeber export and module.export is two pointers and they need to point to the same object forever.

Loading Disqus comments...
Table of Contents