Answers for "useful examples of closures javascript"

1

closures in javascript

// A closure is a function having access to the parent scope, 
// even after the parent function has popped.

function greeting() {
    let message = 'Hi';

    function sayHi() {
        console.log(message);
    }

    return sayHi;
}
let hi = greeting();
hi(); // still can access the message variable
Posted by: Guest on February-01-2022
-1

A closure Function

Cannot GET /about-us.html
Posted by: Guest on July-01-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language