You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following snippet, the returned module contains three properties that all resolve to 'undefined'. While the variables (drawLine, drawRect, drawCircle) are all in scope at the beginning of the function, they would only be initialized after control hits the the return statement.
In the following snippet, the returned module contains three properties that all resolve to 'undefined'. While the variables (drawLine, drawRect, drawCircle) are all in scope at the beginning of the function, they would only be initialized after control hits the the return statement.
To fix this, just change the var statements into named function declarations:
Each of these functions exist for the entire scope of the closure, and will return correctly from the initial return statement.
The text was updated successfully, but these errors were encountered: