Module import/export bindings

Kyle Simpson getify at gmail.com
Sun Mar 15 06:47:09 UTC 2015


From my current understanding (based on other threads), this module:

```js
var foo = 42;
export default foo;
export foo;
foo = 10;
```

When imported:

```js
import foo, * as FOO from "coolmodule";
foo; // 10
FOO.default; // 10
FOO.foo; // 10
```

However, I am curious if this binding is 2-way or only 1-way. What happens if I do:

```js
import foo, * as FOO from "coolmodule";
foo = 100;
FOO.default = 200;
FOO.foo = 300;
```

Have I changed the local `foo` variable inside the module? If so, to which value?

Moreover, what are now the values of these three in my imported context:

```js
foo; // ??
FOO.default; // ??
FOO.foo; // ??
```

Have they all become 300? or are they 100, 200, and 300 separately?


More information about the es-discuss mailing list