I was reading the chapter on Scope Closure, from getify's You don't know JS book series. I feel like I understand how closure works on the surface level at this point, but still can't figure out how this code snippet is exercising closure.
function setupBot(name,selector) {
$( selector ).click( function activator(){
console.log( "Activating: " + name );
} );
}
setupBot( "Closure Bot 1", "#bot_1" );
setupBot( "Closure Bot 2", "#bot_2" );
How I see this is, upon calling the function the variables name and selector in the scope of setupbot are assigned the arguments and function activator is called upon click after which the function returns.
Which function has closure over which scope in this case?