I came across this while watching a video and though they did a good job explaining closures, they did not really explain how the functions were linked. So, I still did not understand how calling newFunction('inside') somehow set the values for both outerVariable and innerVariable. Can anyone explain how this works? Here's the code:
function outerFunction(outerVariable){
return function innerFunction(innerVariable) {
console.log('Outer Variable ' + outerVariable)
console.log('Outer Variable ' + innerVariable)
}
}
const newFunction = outerFunction('outside')
newFunction('inside')