Jorge (2013-06-01T22:44:03.000Z)
On 01/06/2013, at 23:49, Axel Rauschmayer wrote:
> 
> On Jun 1, 2013, at 14:38 , Jorge <jorge at jorgechamorro.com> wrote:
>> 
>> How would this:
>> 
>> (Function () {
>> 
>>  // ...
>> 
>> })();
>> 
>> now look like with arrow functions?
>> 
>> (()=>{
>> 
>>  // ...
>> 
>> })();
>> 
>> What can be left out, if anything?
>> 
> 
> You’ll rarely, if ever, need IIFEs with ES6, thanks to block-scoped function declarations and for-of (which creates a fresh copy of the iteration variable for each iteration).
> 
> Thus, instead of:
> 
> (function () {
>     var tmp = …;
> }());
> 
> you can do:
> 
> {
>     let tmp = …;
> }
> 
> I’d still love to have do-blocks, though.

But they're not fully interchangeable, for example I can exit a function at any point with a return, but can I exit a block at any point with a break or something? Also a function returns a value, does a block evaluate to something?

In any case, I would really like to know which parenthesis or curly braces can I leave out in an immediately invocated arrow function expression, for example this:

var x= (=>{
  //...
})();

Is it correct ES6? Is there anything else that I could rmv in that IIAFE?

Thank you!
-- 
( Jorge )();
github at esdiscuss.org (2013-07-12T02:27:36.872Z)
On 01/06/2013, at 23:49, Axel Rauschmayer wrote:

> You'll rarely, if ever, need IIFEs with ES6, thanks to block-scoped function declarations and for-of (which creates a fresh copy of the iteration variable for each iteration).
> 
> Thus, instead of:
> 
> ```js
> (function () {
>     var tmp = ?;
> }());
> ```
>
> you can do:
> 
> ```js
> {
>     let tmp = ?;
> }
> ```
> 
> I'd still love to have do-blocks, though.

But they're not fully interchangeable, for example I can exit a function at any point with a return, but can I exit a block at any point with a break or something? Also a function returns a value, does a block evaluate to something?

In any case, I would really like to know which parenthesis or curly braces can I leave out in an immediately invocated arrow function expression, for example this:

```js
var x= (=>{
  //...
})();
```

Is it correct ES6? Is there anything else that I could rmv in that IIAFE?