IIFE versus blocks

As ES5 did not provide block scope, a popular pattern to achieve block scope was to use immediately invoked function expressions (IIFE), for example:

    (function () { 
      var block_scoped=0; 
    }()); 
    console.log(block_scoped); //reference error 

With ES6's support for block scopes, you can simply use a let or const declaration.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.218.215