minor
This commit is contained in:
parent
e76364de01
commit
bc9117e70f
10 changed files with 15 additions and 15 deletions
|
@ -46,7 +46,7 @@ For example, here `1+2` results in `3`, and `hello("debugger")` returns nothing,
|
|||
|
||||
## Breakpoints
|
||||
|
||||
Let's examine what's going on within the code. In `hello.js`, click at the line number `4`. Yes, right on the `"4"` digit, not on the code.
|
||||
Let's examine what's going on within the code of the [example page](debugging/index.html). In `hello.js`, click at the line number `4`. Yes, right on the `"4"` digit, not on the code.
|
||||
|
||||
Contratulations! You've set a breakpoint. Please also click on the number for line `8`.
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ let user = {
|
|||
let admin = user;
|
||||
user = null; // overwrite to make things obvious
|
||||
|
||||
admin.sayHi(); // wops! inside sayHi(), the old name is used! error!
|
||||
admin.sayHi(); // Woops! inside sayHi(), the old name is used! error!
|
||||
```
|
||||
|
||||
If we used `this.name` instead of `user.name` inside the `alert`, then the code would work.
|
||||
|
|
|
@ -287,7 +287,7 @@ let obj = {};
|
|||
weakMap.set(obj, "ok"); // works fine (object key)
|
||||
|
||||
*!*
|
||||
weakMap.set("test", "wops"); // Error, because "test" is a primitive
|
||||
weakMap.set("test", "Woops"); // Error, because "test" is a primitive
|
||||
*/!*
|
||||
```
|
||||
|
||||
|
|
|
@ -477,7 +477,7 @@ alert( meetup.date.getDate() ); // Error!
|
|||
*/!*
|
||||
```
|
||||
|
||||
Wops! An error!
|
||||
Woops! An error!
|
||||
|
||||
The value of `meetup.date` is a string, not a `Date` object. How `JSON.parse` may know that it should transform that string into a `Date`?
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ alert( worker.slow(1) ); // the original method works
|
|||
worker.slow = cachingDecorator(worker.slow); // now make it caching
|
||||
|
||||
*!*
|
||||
alert( worker.slow(2) ); // WOPS! Error: Cannot read property 'someMethod' of undefined
|
||||
alert( worker.slow(2) ); // WOOPS! Error: Cannot read property 'someMethod' of undefined
|
||||
*/!*
|
||||
```
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ let rabbit = new Rabbit("White Rabbit", 10); // Error: this is not defined.
|
|||
*/!*
|
||||
```
|
||||
|
||||
Wops! We've got an error. Now we can't create rabbits. What went wrong?
|
||||
Woops! We've got an error. Now we can't create rabbits. What went wrong?
|
||||
|
||||
The short answer is: constructors in inheriting classes must call `super(...)`, and (!) do it before using `this`.
|
||||
|
||||
|
|
|
@ -612,7 +612,7 @@ For instance:
|
|||
*/!*
|
||||
|
||||
function readData() {
|
||||
badFunc(); // wops, something went wrong!
|
||||
badFunc(); // Woops, something went wrong!
|
||||
}
|
||||
|
||||
readData();
|
||||
|
|
|
@ -47,13 +47,13 @@ class ValidationError extends Error {
|
|||
}
|
||||
|
||||
function test() {
|
||||
throw new ValidationError("Wops!");
|
||||
throw new ValidationError("Woops!");
|
||||
}
|
||||
|
||||
try {
|
||||
test();
|
||||
} catch(err) {
|
||||
alert(err.message); // Wops!
|
||||
alert(err.message); // Woops!
|
||||
alert(err.name); // ValidationError
|
||||
alert(err.stack); // a list of nested calls with line numbers for each
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ alert( str.match(reg) ); // <a href="link" class="doc">
|
|||
let str = '...<a href="link1" class="doc">... <a href="link2" class="doc">...';
|
||||
let reg = /<a href=".*" class="doc">/g;
|
||||
|
||||
// Wops! Two links in one match!
|
||||
// Woops! Two links in one match!
|
||||
alert( str.match(reg) ); // <a href="link1" class="doc">... <a href="link2" class="doc">
|
||||
```
|
||||
|
||||
|
|
BIN
figures.sketch
BIN
figures.sketch
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue