(There is another question of similar title out there but I have a different question here.)
It's stated that in ES6, an imported module is "executed" immediately. However, say for example I have exported an object:
let Player = {
player: null,
init(domId, playerId, onReady) {
window.onYouTubeIframeAPIReady = () => {
this.onIframeReady(domId, playerId, onReady)
}
},
...
}
export default Player
Apparently the object only contains properties and methods. Then, I import it in another module:
import Player from "./player"
How can a series of name-value pairs be "executed" though? To execute the constructor of a class when it's imported makes much more sense (is a class's constructor automatically run when it's imported though? I'm also confused on that), but to "execute" an object just doesn't make much sense to me.
Also, if I import a function from another module, does the function gets immediately "evaluated" and its result produced? This also doesn't seem very right to me since a function sometimes requires arguments, which the importing module doesn't automatically provide any.
Maybe I misunderstood the meaning of the word "execute"/"evaluate" here?