Explain the concept of closures in JavaScript.
Example:
function outer() {
let x = 10;
function inner() {
console.log(x);
}
return inner;
}
const closureExample = outer();
closureExample();
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.