JavaScript has a lot of tricks up its sleeve, and higher-order functions (HOFs) are one of the coolest. Whether you're wrangling data, building UIs...
For further actions, you may consider blocking this person and/or reporting abuse
After reading the whole blog, questions answer is :
1
2
1
2
Is it correct ?
It's absolutely correct!!
Well you understand HOF
Nice explanation about Higher Order functions !!
Thanks @hraifi
wow amazing .
thanks @aniruddhadak
1
2
2
4
Hope am correct ππ€£
@bobbyleex ,
Not quite! but still half is correctπ Each call to
createCounter
creates a new independent counter with its owncount
variable.Hereβs what happens:
counter1()
increments its owncount
variable:1
, then2
.counter2()
starts fresh and increments its owncount
:1
, then2
.Output:
Nice explanation
Thanks @jawad_abbas-090 @jawe
I thinks it's answer is :
0
1
0
1
or
0 0 0 0
answer is
1
2
1
2
if i add another log like
console.log(counter2());
then answer will be:
1
2
1
2
3