This commit is contained in:
Ilya Kantor 2017-03-28 10:55:51 +03:00
parent e76364de01
commit bc9117e70f
10 changed files with 15 additions and 15 deletions

View file

@ -46,7 +46,7 @@ For example, here `1+2` results in `3`, and `hello("debugger")` returns nothing,
## Breakpoints ## 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`. Contratulations! You've set a breakpoint. Please also click on the number for line `8`.

View file

@ -157,7 +157,7 @@ let user = {
let admin = user; let admin = user;
user = null; // overwrite to make things obvious 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. If we used `this.name` instead of `user.name` inside the `alert`, then the code would work.

View file

@ -287,7 +287,7 @@ let obj = {};
weakMap.set(obj, "ok"); // works fine (object key) 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
*/!* */!*
``` ```

View file

@ -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`? 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`?

View file

@ -106,7 +106,7 @@ alert( worker.slow(1) ); // the original method works
worker.slow = cachingDecorator(worker.slow); // now make it caching 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
*/!* */!*
``` ```

View file

@ -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`. The short answer is: constructors in inheriting classes must call `super(...)`, and (!) do it before using `this`.

View file

@ -612,7 +612,7 @@ For instance:
*/!* */!*
function readData() { function readData() {
badFunc(); // wops, something went wrong! badFunc(); // Woops, something went wrong!
} }
readData(); readData();

View file

@ -47,13 +47,13 @@ class ValidationError extends Error {
} }
function test() { function test() {
throw new ValidationError("Wops!"); throw new ValidationError("Woops!");
} }
try { try {
test(); test();
} catch(err) { } catch(err) {
alert(err.message); // Wops! alert(err.message); // Woops!
alert(err.name); // ValidationError alert(err.name); // ValidationError
alert(err.stack); // a list of nested calls with line numbers for each alert(err.stack); // a list of nested calls with line numbers for each
} }

View file

@ -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 str = '...<a href="link1" class="doc">... <a href="link2" class="doc">...';
let reg = /<a href=".*" class="doc">/g; 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"> alert( str.match(reg) ); // <a href="link1" class="doc">... <a href="link2" class="doc">
``` ```

Binary file not shown.