iife (immediately invoked function expression)
Page preview (5 pages)
Scroll down 👇
About "iife (immediately invoked function expression)"
tutorial 3: iife, context, new 3.1 iife (immediately invoked function expression) an iife is a function that runs as soon as it is defined. it helps avoid polluting the global scope by encapsulating code. (function () { let secret = "this is hidden"; console.log(secret); // output: this is hidden })(); // console.log(secret); // error: secret is not defined real-world example : initializing a library or module without exposing internal variables. (function () { let apikey = "12345"; function getapikey() { return apikey; } console.log(getapikey()); // output: 12345 })(); 3.2 context (this) the this keyword refers to the context in which a function is called. its value depends on how the function is invoked. 3.2.1 implicit binding when a function is …
This file contains 9 pages in PPTX format (231.1 KB). To download "iife (immediately invoked function expression)", click the Telegram button on the left.