Skip to content

Commit 3cea726

Browse files
committed
Add array inheritance example
1 parent a90dbe7 commit 3cea726

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

JavaScript/5-array.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
const arr1 = ['one', 'two', 'three'];
4+
const arr2 = ['uno', 'due', 'tre'];
5+
Object.setPrototypeOf(arr2, arr1);
6+
7+
console.log({ arr1, arr2 });
8+
delete arr2[1];
9+
console.log({ arr2 });
10+
console.log(arr2[0], arr2[1], arr2[2]);

0 commit comments

Comments
 (0)