const result = (function() {
const secret = 42
return secret
})()
result // β 42
// secret is not accessible outside the IIFEAn IIFE runs immediately and creates its own scope, so inner variables are private and the computed result is exposed only through the return value.
An IIFE is a function that runs immediately after being defined, creating its own scope.
Challenge: Write an IIFE that returns a value immediately. The function should execute and return 42 as soon as it's defined.
Example:
const result = (function() {
return 42
})()
result // 42