Struggling to grasp closure with 3 levels of scopes.
https://jsfiddle.net/Ar2zee/wLy8rkyL/1/
How can I retrieve the value of parameter "g" within the level3 function?
var a = 10;
function level1(b) {
var c = 1;
function level2(f) {
var d = 2;
function level3(g) {
return a + b + c + d + f + g;
}
return level3()
}
return level2;
}
var temp = level1(10);
var temp2 = temp(10);
var temp3 = temp2(10);
console.log(temp3(10)); // or level(10)(); without using a variable
Appreciate any insights!