Create IIFE examples
This commit is contained in:
parent
7db9f71e0e
commit
5149293f5d
17
Chapter 12/IIFE examples
Normal file
17
Chapter 12/IIFE examples
Normal file
@ -0,0 +1,17 @@
|
||||
let val = '1000';
|
||||
|
||||
(function () {
|
||||
console.log('hello');
|
||||
let val = '100'; // local scope variable
|
||||
})();
|
||||
|
||||
let result = (function () {
|
||||
let val = 'Laurence';
|
||||
return val;
|
||||
})();
|
||||
console.log(result);
|
||||
console.log(val);
|
||||
|
||||
(function (val) {
|
||||
console.log(`My name is ${val}`);
|
||||
})('Laurence');
|
||||
Loading…
x
Reference in New Issue
Block a user