Q:

currying vs closure javascript

function closure(){
    function first() { console.log('I was declared first')}
    function second() { console.log('I was declared second')}
    function third() { console.log('I was declared third')}
    return [first, second, third]
}
1
function closuredFunc (){
    function closure(){
    // some logic
    }
}
0
let f = closure()

let one = f[0]
let two = f[1]
let three = f[2]

one() // logs I was declared first
two() // logs I was declared second
three() // logs I was declared third
0

New to Communities?

Join the community