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/05-data-types/09-keys-values-entries/article.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
2
2
# Object.keys, values, entries
3
3
4
-
Let's step away from the individual data structures and talk about the iterations over them.
4
+
Let's step away from the individual data structures and talk about the iterations over them.
5
5
6
6
In the previous chapter we saw methods `map.keys()`, `map.values()`, `map.entries()`.
7
7
8
-
These methods are generic, there is a common agreement to use them for data structures. If we ever create a data structure of our own, we should implement them too.
8
+
These methods are generic, there is a common agreement to use them for data structures. If we ever create a data structure of our own, we should implement them too.
9
9
10
10
They are supported for:
11
11
@@ -23,7 +23,7 @@ For plain objects, the following methods are available:
23
23
-[Object.values(obj)](mdn:js/Object/values) -- returns an array of values.
24
24
-[Object.entries(obj)](mdn:js/Object/entries) -- returns an array of `[key, value]` pairs.
25
25
26
-
...But please note the distinctions (compared to map for example):
26
+
Please note the distinctions (compared to map for example):
27
27
28
28
|| Map | Object |
29
29
|-------------|------------------|--------------|
@@ -32,7 +32,7 @@ For plain objects, the following methods are available:
32
32
33
33
The first difference is that we have to call `Object.keys(obj)`, and not `obj.keys()`.
34
34
35
-
Why so? The main reason is flexibility. Remember, objects are a base of all complex structures in JavaScript. So we may have an object of our own like `order` that implements its own `order.values()` method. And we still can call `Object.values(order)` on it.
35
+
Why so? The main reason is flexibility. Remember, objects are a base of all complex structures in JavaScript. So we may have an object of our own like `data` that implements its own `data.values()` method. And we still can call `Object.values(data)` on it.
36
36
37
37
The second difference is that `Object.*` methods return "real" array objects, not just an iterable. That's mainly for historical reasons.
0 commit comments