Thank you so much. It’s now crystal clear. :) > On Dec 16, 2014, at 12:25 AM, Dave Herman <[email protected]> wrote: > > On Mon, Dec 15, 2014 at 8:16 AM, Glen Huang <[email protected] > <mailto:[email protected]>> wrote: > > So giving the experience of you can merge export and a variable declaration > into a single line, I tried to do: > > export default var pt = { x: 0, y: 0 }; > document.addEventListener(“mousemove”, (ev) => {clientX: pt.x, clientY: pt.y} > = ev); > // hope i got the destructuring assignment right > > Thus this proposal. > > I can see that, and thanks for the field report! Basically the summary is, > any time you want a default export object (as opposed to a function or class, > where you have `export default class` and `export default function` > shorthands) that you also want to refer to internally in the module that > defines it, you'll end up needing a two-liner: > > ```js > var o = { ... }; > export default o; > ``` > > If you only need the properties of the object, not the object itself, one > style you can use is to name all the property values with local variables but > not the object itself: > > ```js > function foo(...) { ... } > function bar(...) { ... } > var baz = ...; > ... > export default { foo, bar, baz }; > ``` > > So obviously “merging” concept doesn’t apply when default is involved, and I > now know why. Thanks again. > > No worries. JFTR, as I alluded to above, if you're exporting a function or > class, you *do* get the merging: > > ```js > export default class Foo { > ... > } > var x = new Foo(...); > ... > ``` > > Dave >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

