Skip to content

Commit a77f124

Browse files
committed
concat 2 arrays
1 parent 4e76ecc commit a77f124

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

js/Array.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,11 @@ const index = array.indexOf(itemToBeRemoved);
6969
if (index !== -1) {
7070
array.splice(index, 1, itemToBeInserted);
7171
}
72+
73+
// concat 2 arrays
74+
const arrayA = [1, 2, 3];
75+
const arrayB = [4, 5, 6];
76+
const array_AandB = arrayA.concat(arrayB);
77+
// alterantive
78+
const array_AandB = [...arrayA, ...arrayB];
79+

0 commit comments

Comments
 (0)