(function(name){
console.log("Hello "+name);
})('Shirshak'); //Hello Shirshak
//using function expression
var name = function (){
console.log("Hello "+name) //Hello Shirshak
}();
result = (function(a, b){
return a - b;
})(100, 42);
console.log(result); // 58
(() => {
/* */
})()
(function() {
/* */
})()
(function () {
var aName = "Barry";
})();
// Variable aName is not accessible from the outside scope
aName // throws "Uncaught ReferenceError: aName is not defined"
(function(name){
console.log("Hello "+name);
})('Shirshak'); //Hello Shirshak
//using function expression
var name = function (){
console.log("Hello "+name) //Hello Shirshak
}();
result = (function(a, b){
return a - b;
})(100, 42);
console.log(result); // 58
(() => {
/* */
})()
(function() {
/* */
})()
(function () {
var aName = "Barry";
})();
// Variable aName is not accessible from the outside scope
aName // throws "Uncaught ReferenceError: aName is not defined"