Skip to content

Commit 8d4df20

Browse files
committed
minor fixes
1 parent 3bfb6cd commit 8d4df20

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

1-js/05-data-types/02-number/article.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ Please note that an empty or a space-only string is treated as `0` in all numeri
342342
```js run
343343
alert( Number.isNaN(NaN) ); // true
344344
alert( Number.isNaN("str" / 2) ); // true
345-
345+
346346
// Note the difference:
347347
alert( Number.isNaN("str") ); // false, because "str" belongs to the string type, not the number type
348348
alert( isNaN("str") ); // true, because isNaN converts string "str" into a number and gets NaN as a result of this conversion
@@ -354,24 +354,24 @@ Please note that an empty or a space-only string is treated as `0` in all numeri
354354
alert( Number.isFinite(123) ); // true
355355
alert( Number.isFinite(Infinity) ); //false
356356
alert( Number.isFinite(2 / 0) ); // false
357-
357+
358358
// Note the difference:
359359
alert( Number.isFinite("123") ); // false, because "123" belongs to the string type, not the number type
360360
alert( isFinite("123") ); // true, because isFinite converts string "123" into a number 123
361361
```
362-
363-
Do not consider `Number.isNaN` and `Number.isFinite` methods as the more "correct" versions of `isNaN` and `isFinite` functions. They complement each other and are equally essential for different tasks.
362+
363+
In a way, `Number.isNaN` and `Number.isFinite` are simpler and more straightforward than `isNaN` and `isFinite` functions. In practice though, `isNaN` and `isFinite` are mostly used, as they're shorter to write.
364364
````
365365

366-
```smart header="Compare with `Object.is`"
366+
```smart header="Comparison with `Object.is`"
367367
There is a special built-in method `Object.is` that compares values like `===`, but is more reliable for two edge cases:
368368

369369
1. It works with `NaN`: `Object.is(NaN, NaN) === true`, that's a good thing.
370370
2. Values `0` and `-0` are different: `Object.is(0, -0) === false`, technically that's true, because internally the number has a sign bit that may be different even if all other bits are zeroes.
371371

372372
In all other cases, `Object.is(a, b)` is the same as `a === b`.
373373

374-
This way of comparison is often used in JavaScript specification. When an internal algorithm needs to compare two values for being exactly the same, it uses `Object.is` (internally called [SameValue](https://tc39.github.io/ecma262/#sec-samevalue)).
374+
We mention `Object.is` here, because it's often used in JavaScript specification. When an internal algorithm needs to compare two values for being exactly the same, it uses `Object.is` (internally called [SameValue](https://tc39.github.io/ecma262/#sec-samevalue)).
375375
```
376376

377377

0 commit comments

Comments
 (0)