+ 1

can we not access arrow function before inisialization?

https://code.sololearn.com/cTxKAQuXAhpa/?ref=app

10th Aug 2021, 6:26 PM
CodeSmith
CodeSmith - avatar
3 ответов
+ 2
No, this would be like accessing any other variable prior to initialization. Here, 'sum' is a variable that holds an alias for the anonymous arrow function, so it is treated similarly to any other variable and not like a normal function etc.
10th Aug 2021, 6:42 PM
ChaoticDawg
ChaoticDawg - avatar
+ 2
If you are using an arrow function inline or passing as an argument to another function without an alias, then the arrow function needs to be fully defined. If you are using an alias variable for an arrow function then, yes, that alias must be initialized with a fully defined arrow function prior to being called.
10th Aug 2021, 7:10 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
ChaoticDawg are arrow functions meant to be initialized before call?
10th Aug 2021, 6:48 PM
CodeSmith
CodeSmith - avatar