Skip to content

Commit 746ba74

Browse files
committed
Collection concatination examples
1 parent 86dcd9b commit 746ba74

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

JavaScript/2-concat.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
const arr1 = [
4+
'Marcus Aurelius',
5+
'Commodus Antoninus',
6+
'Victor Glushkov',
7+
];
8+
9+
const arr2 = [
10+
'Ibn Arabi',
11+
'Mao Zedong',
12+
'Rene Descartes',
13+
];
14+
15+
const arrConcat1 = arr1.concat(arr2);
16+
const arrConcat2 = [...arr1, ...arr2];
17+
18+
console.dir({ arrConcat1, arrConcat2 });

JavaScript/3-object.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
const obj1 = {
4+
'Marcus Aurelius': '212-04-26',
5+
'Commodus Antoninus': '312-04-26',
6+
'Victor Glushkov': '1923-08-24',
7+
};
8+
9+
const obj2 = {
10+
'Ibn Arabi': '1165-11-16',
11+
'Mao Zedong': '1893-12-26',
12+
'Rene Descartes': '1596-03-31',
13+
};
14+
15+
const objConcat1 = Object.assign({}, obj1, obj2);
16+
const objConcat2 = { ...obj1, ...obj2 };
17+
18+
console.dir({ objConcat1, objConcat2 });

0 commit comments

Comments
 (0)