closure vs currying code example
Example 1: 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]
}
Example 2: currying vs closure javascript
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