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
{{ message }}
Repository navigation
Commit a72b96f
Browse filesBrowse the repository at this point in the historyBrowse files
Keep the localized exercise definitions in one Markdown file per locale while preserving their exact placement in the article through stable references. Register the nested exercise source so translation drift can be tracked independently from the surrounding answer.
-`declared()` returns `'function declaration'`. Function declarations are fully hoisted — both the identifier binding and the function body are available from the top of the scope.
211
177
-`expressed()` throws `TypeError: expressed is not a function`. The `var expressed` binding is hoisted and initialized to `undefined`, but the assignment of the function expression happens at its source location. Calling `undefined()` produces the `TypeError`.
-[ ]`both-log-values`: Both strings are logged successfully.
23
+
-[x]`declaration-then-type-error`: `'function declaration'` is logged, then calling `expressed` throws a `TypeError`.
24
+
-[ ]`reference-error-before-output`: A `ReferenceError` is thrown before anything is logged.
25
+
26
+
### Explanation
27
+
28
+
Function declarations are initialized with their function body before execution. The `var expressed` binding is also available, but its function assignment has not run yet, so its value is `undefined` and calling it throws a `TypeError`.
-[ ]`both-log-values`: As duas strings são exibidas normalmente.
23
+
-[x]`declaration-then-type-error`: `'function declaration'` é exibido e, em seguida, chamar `expressed` lança um `TypeError`.
24
+
-[ ]`reference-error-before-output`: Um `ReferenceError` é lançado antes de qualquer saída.
25
+
26
+
### Explanation
27
+
28
+
Declarações de função são inicializadas com o corpo da função antes da execução. A associação `var expressed` também existe, mas a atribuição da função ainda não ocorreu. Portanto, seu valor é `undefined` e chamá-la lança um `TypeError`.
Variáveis declaradas via `let` e `const` também sofrem o hoisted. No entanto, ao contrário de `var` e `function`, eles não são inicializados e acessá-los antes que a declaração resulte em uma exceção `ReferenceError`. A variável está em uma "zona temporária morta" desde o início do bloco até que a declaração seja processada.
0 commit comments