minor fixes

This commit is contained in:
Ilya Kantor 2021-06-27 15:24:42 +03:00
parent 8db65194dc
commit 8752573cf3

View file

@ -77,7 +77,7 @@ Objects lack many methods that exist for arrays, e.g. `map`, `filter` and others
If we'd like to apply them, then we can use `Object.entries` followed by `Object.fromEntries`: If we'd like to apply them, then we can use `Object.entries` followed by `Object.fromEntries`:
1. Use `Object.entries(obj)` to get an array of key/value pairs from `obj`. 1. Use `Object.entries(obj)` to get an array of key/value pairs from `obj`.
2. Use array methods on that array, e.g. `map`, to transform key/value pairs. 2. Use array methods on that array, e.g. `map`, to transform these key/value pairs.
3. Use `Object.fromEntries(array)` on the resulting array to turn it back into an object. 3. Use `Object.fromEntries(array)` on the resulting array to turn it back into an object.
For example, we have an object with prices, and would like to double them: For example, we have an object with prices, and would like to double them:
@ -98,6 +98,6 @@ let doublePrices = Object.fromEntries(
*/!* */!*
alert(doublePrices.meat); // 8 alert(doublePrices.meat); // 8
``` ```
It may look difficult at first sight, but becomes easy to understand after you use it once or twice. We can make powerful chains of transforms this way. It may look difficult at first sight, but becomes easy to understand after you use it once or twice. We can make powerful chains of transforms this way.