iife js code example
Example 1: immediate invoke function js
(function () {
statements
})();
Example 2: javascript Immediately Invoked Function Expression
result = (function(a, b){
return a - b;
})(100, 42);
console.log(result);
Example 3: iife javascript
var result = (function () {
var name = "Barry";
return name;
})();
result;
Example 4: immediate invoke function js
(() => {
})();
Example 5: Immediately-Invoked Function javascript
(function() {
})()
Example 6: immediately invoked function expression
(function () {
var aName = "Barry";
})();
aName