minor fixes

This commit is contained in:
Ilya Kantor 2022-01-21 10:45:48 +03:00
parent eb23b2d7b8
commit d5128182a5
2 changed files with 9 additions and 3 deletions

View file

@ -46,13 +46,15 @@ Besides regular numbers, there are so-called "special numeric values" which also
alert( "not a number" / 2 ); // NaN, such division is erroneous
```
`NaN` is sticky. Any further operation on `NaN` returns `NaN`:
`NaN` is sticky. Any further mathematical operation on `NaN` returns `NaN`:
```js run
alert( "not a number" / 2 + 5 ); // NaN
alert( NaN + 1 ); // NaN
alert( 3 * NaN ); // NaN
alert( "not a number" / 2 - 1 ); // NaN
```
So, if there's a `NaN` somewhere in a mathematical expression, it propagates to the whole result.
So, if there's a `NaN` somewhere in a mathematical expression, it propagates to the whole result (there's only one exception to that: `NaN ** 0` is `1`).
```smart header="Mathematical operations are safe"
Doing maths is "safe" in JavaScript. We can do anything: divide by zero, treat non-numeric strings as numbers, etc.

View file

@ -59,6 +59,10 @@ alert( str.match(/\d+\b(?!€)/g) ); // 2 (the price is not matched)
## Lookbehind
```warn header="Lookbehind browser compatibility"
Please Note: Lookbehind is not supported in non-V8 browsers, such as Safari, Internet Explorer.
```
Lookahead allows to add a condition for "what follows".
Lookbehind is similar, but it looks behind. That is, it allows to match a pattern only if there's something before it.