Immediately-invoked Function es6 code example
Example 1: javascript Immediately Invoked Function Expression
result = (function(a, b){
return a - b;
})(100, 42);
console.log(result); // 58
Example 2: Immediately-Invoked Function javascript
(() => {
/* */
})()
Example 3: immediately invoked function expression
(function () {
var aName = "Barry";
})();
// Variable aName is not accessible from the outside scope
aName // throws "Uncaught ReferenceError: aName is not defined"