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: 1-js/02-first-steps/03-strict-mode/article.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,9 +53,17 @@ For the future, when you use a browser console to test features, please note tha
53
53
54
54
Sometimes, when `use strict` makes a difference, you'll get incorrect results.
55
55
56
-
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.
56
+
You can try to press `key:Shift+Enter` to input multiple lines, and put `use strict` on top, like this:
57
57
58
-
The reliable way to ensure `use strict` would be to input the code into console like this:
58
+
```js
59
+
'use strict'; <Shift+Enter for a newline>
60
+
// ...your code
61
+
<Enter to run>
62
+
```
63
+
64
+
It works in most browsers, namely Firefox and Chrome.
65
+
66
+
If it doesn't, the most reliable way to ensure `use strict` would be to input the code into console like this:
Copy file name to clipboardExpand all lines: 9-regular-expressions/10-regexp-backreferences/article.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Backreferences in pattern: \n and \k
2
2
3
-
Capturing groups can be accessed not only in the result or in the replacement string, but also in the pattern itself.
3
+
We can use the contents of capturing groups `(...)` not only in the result or in the replacement string, but also in the pattern itself.
4
4
5
5
## Backreference by number: \n
6
6
@@ -12,7 +12,7 @@ We need to find a quoted string: either a single-quoted `subject:'...'` or a dou
12
12
13
13
How to look for them?
14
14
15
-
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!"`:
15
+
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!"`:
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.
27
27
28
-
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.
28
+
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.
0 commit comments