Answer the question
In order to leave comments, you need to log in
Why is it possible to call a function before the declaration?
Can you tell me why there is no error when I call a function before it is declared?
I understand that the function can be in a closure, but this is a potential bug.
For example, if I call test immediately after the declaration
Answer the question
In order to leave comments, you need to log in
Typescript itself does not check this situation, you need to use a linter
If you call test before the declaration of setCitiesError, then there will be an error, and if after, then setCitiesError will already be in memory
In Javascript, this is called hoisting Read
here - https://developer.mozilla.org/en/docs/%D0%A1%D0%BB...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question