I'm trying to understand some code :
(function (exports) {
exports.myProperty = "azerty";
console.log(exports)
}((this.myModule = this.myModule || {})));
What I understood from this code :
1) I'm executing an IIFE and "this" represents Window (the global object).
2) Since Window doesn't have a myModule property, this.myModule = this.myModule adds a new property to Window object and this property is undefined.
3) (this.myModule=this.myModule) || {} returns {} so exports equals {} (empty object)
4) I'm adding a property "myProperty" to export object so export = {myProerty: "azerty"}
What I don't understand : after executing this code, when I console.log(window), I can see that :
Window object has a property myModule equals to the exports object. How the relation between myModule and {myProperty: "azerty"} has been resolved ? I can't understand this part.