diff --git a/1-js/02-first-steps/03-strict-mode/article.md b/1-js/02-first-steps/03-strict-mode/article.md index 0aab0689..891b8fba 100644 --- a/1-js/02-first-steps/03-strict-mode/article.md +++ b/1-js/02-first-steps/03-strict-mode/article.md @@ -53,9 +53,17 @@ For the future, when you use a browser console to test features, please note tha Sometimes, when `use strict` makes a difference, you'll get incorrect results. -Even if we press `key:Shift+Enter` to input multiple lines, and put `use strict` on top, it doesn't work. That's because of how the console executes the code internally. +You can try to press `key:Shift+Enter` to input multiple lines, and put `use strict` on top, like this: -The reliable way to ensure `use strict` would be to input the code into console like this: +```js +'use strict'; +// ...your code + +``` + +It works in most browsers, namely Firefox and Chrome. + +If it doesn't, the most reliable way to ensure `use strict` would be to input the code into console like this: ```js (function() { diff --git a/9-regular-expressions/10-regexp-backreferences/article.md b/9-regular-expressions/10-regexp-backreferences/article.md index a7a934e4..eff5cab4 100644 --- a/9-regular-expressions/10-regexp-backreferences/article.md +++ b/9-regular-expressions/10-regexp-backreferences/article.md @@ -1,6 +1,6 @@ # Backreferences in pattern: \n and \k -Capturing groups can be accessed not only in the result or in the replacement string, but also in the pattern itself. +We can use the contents of capturing groups `(...)` not only in the result or in the replacement string, but also in the pattern itself. ## Backreference by number: \n @@ -12,7 +12,7 @@ We need to find a quoted string: either a single-quoted `subject:'...'` or a dou How to look for them? -We can put two kinds of quotes in the pattern: `pattern:['"](.*?)['"]`, but it would find strings with mixed quotes, like `match:"...'` and `match:'..."`. That would lead to incorrect matches when one quote appears inside other ones, like the string `subject:"She's the one!"`: +We can put both kinds of quotes in the square brackets: `pattern:['"](.*?)['"]`, but it would find strings with mixed quotes, like `match:"...'` and `match:'..."`. That would lead to incorrect matches when one quote appears inside other ones, like the string `subject:"She's the one!"`: ```js run let str = `He said: "She's the one!".`; @@ -25,7 +25,7 @@ alert( str.match(reg) ); // "She' As we can see, the pattern found an opening quote `match:"`, then the text is consumed lazily till the other quote `match:'`, that closes the match. -To make sure that the pattern looks for the closing quote exactly the same as the opening one, we can make a groups of it and use the backreference. +To make sure that the pattern looks for the closing quote exactly the same as the opening one, we can wrap it into a capturing group and use the backreference. Here's the correct code: