Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #34787

Re: No need for IIFEs any more?

Newsgroups comp.lang.javascript
Date 2018-03-15 21:54 -0700
References <1c492da9-76d8-4c70-8c73-1c6e2f8baa23@googlegroups.com> <p89gkv$142r$1@gioia.aioe.org>
Message-ID <87922ffc-6076-413b-b671-07e546812b3f@googlegroups.com> (permalink)
Subject Re: No need for IIFEs any more?
From RobG <rgqld@iinet.net.au>

Show all headers | View raw


On Wednesday, March 14, 2018 at 7:43:05 AM UTC+10, Joao Rodrigues wrote:
> On 13/03/2018 01:42, RobG wrote:
> > Since block scoped variables were introduced in ECMAScript 2015,
> > it's been possible to implement the same "private variable" functionality as
> > is available using the IIFE pattern.
> 
> > [snip]
> 
> You may replace an IIFE with a block and a let or const declaration 
> (*don't use 'var' in this case*) or a module in ES6. There were some 
> examples of that in the book 'Exploring ES6', section 12.3.5, by Dr. 
> Axel Rauschmayer:
> 
> <http://exploringjs.com/es6/ch_callables.html#sec_iifes-in-es6>

Thanks, I'll check it out.

 
> There's also the possibility of using an Immediately-Invoked Arrow 
> Function (IIAF) in ES6. For example:
[...]

Yes, but that's just an IIFE using arrow function syntax. It also changes the behaviour of *this* in the function, so not a pattern that can be adopted for general replacement.

> BTW, your getNext() function may be refactored to a Generator in ES6:

Sure, it was just the simplest practical example I could think of. ;-)

-- 
Rob

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

No need for IIFEs any more? RobG <rgqld@iinet.net.au> - 2018-03-12 21:42 -0700
  Re: No need for IIFEs any more? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-03-13 13:27 -0700
    Re: No need for IIFEs any more? RobG <rgqld@iinet.net.au> - 2018-03-15 21:47 -0700
  Re: No need for IIFEs any more? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2018-03-13 18:43 -0300
    Re: No need for IIFEs any more? RobG <rgqld@iinet.net.au> - 2018-03-15 21:54 -0700

csiph-web