Skip to content

Commit 294b1a8

Browse files
authored
use slice instead of forEach
1 parent 18e2e47 commit 294b1a8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎fixed size array‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function createFixedSizeArray(...items) {
44
if (items.length === 1) {
55
array = (new Array(items[0])).fill(undefined);
66
} else {
7-
items.forEach((item, index) => array[index] = item)
7+
array = items.slice(0)
88
}
99

1010
Object.seal(array);
@@ -20,7 +20,7 @@ class FixedArray {
2020
if (items.length === 1) {
2121
array = (new Array(items[0])).fill(undefined);
2222
} else {
23-
items.forEach((item, index) => array[index] = item)
23+
array = items.slice(0)
2424
}
2525

2626
Object.seal(array);

0 commit comments

Comments
 (0)