How does parameter of closure pass down to inner function?

27 Views Asked by At

recently , I'm learning coding , and here's the code of teaching closure

function accumulator(){
    let sum =0;
    return (num) =>{
        sum = sum + num;
        return sum;
    }
}

const acc = accumulator();

acc(3)
acc(5)

result :3 & 8

Now , I've a question , why the parameter of acc(3) which is equal to accumulator(3) can be passed down to inner function parameter num , (num)=> , without any variable declared? any concept involved in closure?

0

There are 0 best solutions below