Why is "export default var a = 1;" invalid syntax?

Glen Huang curvedmark at gmail.com
Wed May 6 05:41:14 UTC 2015


That's not enough:

```js
let a = 1;
setTimeout(() => a = 2, 100);
export default a;
``` 
You can't export 2 in this case.

> On May 6, 2015, at 1:36 PM, Bucaran <jbucaran at me.com> wrote:
> 
> So, basically, just like we usually `import` everything at the top, maybe we should `export` everything at the bottom.
> 
> 
>> On May 6, 2015, at 2:33 PM, Glen Huang <curvedmark at gmail.com> wrote:
>> 
>> The point is to keep the binding:
>> 
>> ```js
>> export default let a = 1;
>> a = 2;
>> ``` 
>> exports value 2
>> 
>> ```js
>> let a = 1
>> export default a;
>> a = 2;
>> ```
>> exports value 1
>> 
>>> On May 6, 2015, at 1:18 PM, Bucaran <jbucaran at me.com> wrote:
>>> 
>>> Read as much as I could, but it was getting too long, so just to quickly summarize:
>>> 
>>> While you can’t:
>>> 
>>> 
>>> ```js
>>> export default let a = 1
>>> ``` 
>>> 
>>> 
>>> You certainly can:
>>> 
>>> 
>>> ```js
>>> let a = 1
>>> export default a
>>> ```
>>> 
>>> Or 
>>> 
>>> ```js
>>> let a = 1
>>> let b = 2
>>> let c = 3
>>> 
>>> export default {
>>> A: a,
>>> B: b,
>>> C: c
>>> }
>>> ```
>>> 
>>> Cheers
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>> 
> 



More information about the es-discuss mailing list