minor
This commit is contained in:
parent
8fc01fa0fe
commit
a4a16fccd6
8 changed files with 105 additions and 26 deletions
|
@ -161,7 +161,7 @@ let user = {
|
|||
let admin = user;
|
||||
user = null; // overwrite to make things obvious
|
||||
|
||||
admin.sayHi(); // Woops! inside sayHi(), the old name is used! error!
|
||||
admin.sayHi(); // Whoops! 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", "Woops"); // Error, because "test" is a primitive
|
||||
weakMap.set("test", "Whoops"); // Error, because "test" is a primitive
|
||||
*/!*
|
||||
```
|
||||
|
||||
|
|
|
@ -477,7 +477,7 @@ alert( meetup.date.getDate() ); // Error!
|
|||
*/!*
|
||||
```
|
||||
|
||||
Woops! An error!
|
||||
Whoops! 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`?
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ let rabbit = new Rabbit("White Rabbit", 10); // Error: this is not defined.
|
|||
*/!*
|
||||
```
|
||||
|
||||
Woops! We've got an error. Now we can't create rabbits. What went wrong?
|
||||
Whoops! 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(); // Woops, something went wrong!
|
||||
badFunc(); // Whoops, something went wrong!
|
||||
}
|
||||
|
||||
readData();
|
||||
|
|
|
@ -47,13 +47,13 @@ class ValidationError extends Error {
|
|||
}
|
||||
|
||||
function test() {
|
||||
throw new ValidationError("Woops!");
|
||||
throw new ValidationError("Whoops!");
|
||||
}
|
||||
|
||||
try {
|
||||
test();
|
||||
} catch(err) {
|
||||
alert(err.message); // Woops!
|
||||
alert(err.message); // Whoops!
|
||||
alert(err.name); // ValidationError
|
||||
alert(err.stack); // a list of nested calls with line numbers for each
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue