mirror of
https://github.com/bendtherules/blog-hashnode-backup.git
synced 2026-08-18 13:42:04 +00:00
update post: How does in-built Array iterator work?
This commit is contained in:
@@ -76,7 +76,7 @@ Now that we have the in-built array iterator, the most important thing is knowin
|
|||||||
|
|
||||||
## 🤯 Implications
|
## 🤯 Implications
|
||||||
|
|
||||||
1. `[...arr]` converts sparse array to dense array. [⭐️1️⃣ above](#note-1)
|
1. `[...arr]` converts sparse array to dense array. (Reason -⭐️ 1️⃣ above)
|
||||||
|
|
||||||
```js
|
```js
|
||||||
foo = [10, , 30, 40]; // [10, <hole>, 30, 40]
|
foo = [10, , 30, 40]; // [10, <hole>, 30, 40]
|
||||||
@@ -93,7 +93,7 @@ Object.keys(foo) // 0, 2, 3
|
|||||||
foo.keys(); // 0, 1, 2, 3
|
foo.keys(); // 0, 1, 2, 3
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Array iterator will never return more values after it has finished once - even if the array has more values now. [⭐️2️⃣ above](#note-2)
|
2. Array iterator will never return more values after it has finished once - even if the array has more values now. (Reason - ⭐️ 2️⃣ above)
|
||||||
|
|
||||||
```js
|
```js
|
||||||
arr = [10]
|
arr = [10]
|
||||||
|
|||||||
Reference in New Issue
Block a user