-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge-41.js
More file actions
26 lines (22 loc) · 861 Bytes
/
challenge-41.js
File metadata and controls
26 lines (22 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const myInfo = {
user: "Elzero",
age: 41,
country: "Egypt",
};
const clone1 = { ...myInfo };
const clone2 = Object.assign({}, myInfo);
const clone3 = structuredClone(myInfo);
const clone4 = JSON.parse(JSON.stringify(myInfo));
const clone5 = {};
for (const key of Object.keys(myInfo)) {
clone5[key] = myInfo[key];
}
const clone6 = new Object(myInfo);
const clone7 = myInfo;
console.log(clone1); // {user: 'Elzero', age: 41, country: 'Egypt'}
console.log(clone2); // {user: 'Elzero', age: 41, country: 'Egypt'}
console.log(clone3); // {user: 'Elzero', age: 41, country: 'Egypt'}
console.log(clone4); // {user: 'Elzero', age: 41, country: 'Egypt'}
console.log(clone5); // {user: 'Elzero', age: 41, country: 'Egypt'}
console.log(clone6); // {user: 'Elzero', age: 41, country: 'Egypt'}
console.log(clone7); // {user: 'Elzero', age: 41, country: 'Egypt'}