Today I learn what is closure in JavaScript, I have search many contents and videos and finally they defines to create a nested function create a outer function and create the inner function and you will use the outer function in the inner function it can accessible.
Example:
function titles(){
outervariable="vi"
function subtitle(){
let innervariable="jay"
console.log(outervariable+innervariable)
}
return subtitle()
}
const name1=titles();
name1
Top comments (0)