+ 2

quick question

Hey guys, can you please explain to me what does it mean closure[0](6) what exactly mean having [] and () next to each other?

6th May 2020, 6:53 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
4 Answers
+ 3
I'm not quite sure but maybe the closure array's first element (index 0) is a function that takes 1 argument. for example const foo = (val) => { console.log(val); } const arr = [foo, 10, 20]; arr[0](6);
6th May 2020, 6:59 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 3
Khaled, that is how you pass argument to a function. function foo(a) { console.log(a); } //In simple function call we do it like this foo(6); But since our function is part of that array, we call it that way.
6th May 2020, 7:13 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 1
Got you Rick, Thank you so much ^^
6th May 2020, 7:16 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
0
yes Rick the closure arguments are a function and integer. I could not understand what the (6) means.
6th May 2020, 7:11 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar