javascript iffe 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 expression
(function () {
statements
})();
Example 3: iife
/*An IIFE (Immediately Invoked Function Expression) is a JavaScript
function that runs as soon as it is defined
*/
(function () {
//write your js code here
});