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
Copy file name to clipboardExpand all lines: 08_error.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ canYouSpotTheProblem();
54
54
55
55
{{index "let keyword", [binding, global]}}
56
56
57
-
Normally, when you forget to put `let` in front of your binding, as with `counter` in the example, JavaScript quietly creates a global binding and uses that. In strict mode, an ((error)) is reported instead. This is very helpful. It should be noted, though, that this doesn't work when the binding in question already exists as a global binding. In that case, the loop will still quietly overwrite the value of the binding.
57
+
Normally, when you forget to put `let` in front of your binding, as with `counter` in the example, JavaScript quietly creates a global binding and uses that. In strict mode, an ((error)) is reported instead. This is very helpful. It should be noted, though, that this doesn't work when the binding in question already exists somewhere in scope. In that case, the loop will still quietly overwrite the value of the binding.
@@ -315,7 +315,7 @@ The `throw` keyword is used to raise an exception. Catching one is done by wrapp
315
315
316
316
{{index debugging, "call stack", "Error type"}}
317
317
318
-
In this case, we used the `Error` ((constructor)) to create our exception value. This is a ((standard)) JavaScript constructor that creates an object with a `message` property. In most JavaScript environments, instances of this constructor also gather information about the call stack that existed when the exception was created, a so-called _((stack trace))_. This information is stored in the `stack` property and can be helpful when trying to debug a problem: it tells us the function where the problem occurred and which functions made the failing call.
318
+
In this case, we used the `Error` ((constructor)) to create our exception value. This is a ((standard)) JavaScript constructor that creates an object with a `message` property. Instances of `Error` also gather information about the call stack that existed when the exception was created, a so-called _((stack trace))_. This information is stored in the `stack` property and can be helpful when trying to debug a problem: it tells us the function where the problem occurred and which functions made the failing call.
319
319
320
320
{{index "exception handling"}}
321
321
@@ -613,12 +613,12 @@ function withBoxUnlocked(body) {
613
613
// Your code here.
614
614
}
615
615
616
-
withBoxUnlocked(function() {
616
+
withBoxUnlocked(() => {
617
617
box.content.push("gold piece");
618
618
});
619
619
620
620
try {
621
-
withBoxUnlocked(function() {
621
+
withBoxUnlocked(() => {
622
622
throw new Error("Pirates on the horizon! Abort!");
0 commit comments