self calling function javascript code example
Example 1: self invoked function javascript
(function(){
//Bunch of code...
})();
Example 2: self invoking function javascript es6
(() => {
console.log('Ok');
})()
Example 3: self calling function
(function(){
console.log(Math.PI);
})();
Example 4: call a self executing function javascript
var foo = (function bar() {
alert('hello');
return bar;
})(); // hello
foo(); // hello