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
What specific section or headline is this issue about?
Function scope and conflicts
What information was incorrect, unhelpful, or incomplete?
The example provided under the "Function scope and conflicts" section could be misleading as it implies that JavaScript always prioritizes the greeting() function from the first.js file, ignoring the greeting() function from second.js. While this is the observed behavior due to the const redeclaration error halting the execution of second.js, it could give the impression that JavaScript automatically "prefers" the first declared function in cases of conflicts, which is not true.
This could confuse beginners into thinking that JavaScript inherently ignores duplicate functions in later scripts, which contradicts standard behavior where later declarations overwrite earlier ones unless there's a blocking error.
What did you expect to see?
A clearer explanation about why second.js fails to execute in this specific example, emphasizing:
The role of the const redeclaration error in halting the execution of second.js.
The typical behavior of JavaScript, where functions and variables declared later overwrite earlier ones unless an error stops execution.
Additionally, a more robust example demonstrating this behavior could be helpful. For instance:
Using let or var instead of const to show how the greeting() function from second.js would overwrite the one from first.js.
Explicitly highlighting that errors like const redeclarations affect execution flow.
Do you have any supporting links, references, or citations?
MDN URL
https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Scripting/Functions
What specific section or headline is this issue about?
Function scope and conflicts
What information was incorrect, unhelpful, or incomplete?
The example provided under the "Function scope and conflicts" section could be misleading as it implies that JavaScript always prioritizes the greeting() function from the first.js file, ignoring the greeting() function from second.js. While this is the observed behavior due to the const redeclaration error halting the execution of second.js, it could give the impression that JavaScript automatically "prefers" the first declared function in cases of conflicts, which is not true.
This could confuse beginners into thinking that JavaScript inherently ignores duplicate functions in later scripts, which contradicts standard behavior where later declarations overwrite earlier ones unless there's a blocking error.
What did you expect to see?
A clearer explanation about why second.js fails to execute in this specific example, emphasizing:
Additionally, a more robust example demonstrating this behavior could be helpful. For instance:
Using let or var instead of const to show how the greeting() function from second.js would overwrite the one from first.js.
Explicitly highlighting that errors like const redeclarations affect execution flow.
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
MDN metadata
Page report details
en-us/learn_web_development/core/scripting/functions
The text was updated successfully, but these errors were encountered: