I am confused with the scoping of closure expression. I don't understand why output is 40 only.
js
function multiply(input) {
var no = 5;
function multiply2(mul) {
mul *= input;
return no * mul;
}
return multiply2;
}
var total = multiply(4);
var result = total(2);
console.log("result :",result);
Output
result :40
2 * 4 = 8and8 * 5 = 40.mul *= input;andreturn no * mul;. Now you need to look at what the values ofmul,inputandnoare.