+ 6

javascript

Fill in the blanks to copy the user object to the new user object by destructuring the name and age properties. Pass the value 9999 for the id property. const user = { name: 'David', age: 28, id: 1234 }; let newUser = Object.assign({}, {name, age} =____ , {id : 9999}); console.log(newUser);

6th Jun 2019, 7:47 AM
Himanshu Handa
Himanshu Handa - avatar
15 Answers
+ 17
It's really simple. If you want to copy info from user you have to pass that in blank. For example : const user = { name: 'David', age: 28, id: 1234 }; let newUser = Object.assign({}, {name, age} = user, {id : 9999}); console.log(newUser.name);
6th Jun 2019, 7:50 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
Just to add onto this if you want more information, this is called "object destructuring". https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
16th Jun 2019, 4:26 AM
JS Coder
+ 2
Answer is here.. const user = { name: 'David', age: 28, id: 1234 }; let newUser = Object.assign({}, {name, age } = user , { id : 9999}); console.log(newUser);
5th Aug 2019, 7:41 PM
Aftab Ashraf
Aftab Ashraf - avatar
+ 2
Fill in the blanks to copy the user object to the newUser object by destructuring the name and age properties. Pass the value 9999 for the id property. const user = { name: 'David', age: 28, id: 1234 }; let newUser = Object.assign({}, {name, age } = user , { id : 9999}); console.log(newUser);
24th Dec 2019, 9:38 AM
Rana Abid
Rana Abid - avatar
+ 2
name user id
25th Jul 2020, 4:29 PM
Ekundayo Timileyin
+ 1
const user = { name: 'David', age: 28, id: 1234}; let newUser = Object.assign({}, {name, age } = user , { id : 9999}); console.log(newUser); > Object { name: "David", age: 28, id: 9999 }
11th Mar 2020, 8:55 AM
Halil Turkmen
Halil Turkmen - avatar
+ 1
age user id
20th Sep 2022, 11:58 AM
LIPSA BEHERA
0
const user = { name: 'David', age: 28, id: 1234 }; let newUser = Object.assign({}, {name, age } = user , { id : 9999}); console.log(newUser);
24th Dec 2019, 9:14 AM
Rana Abid
Rana Abid - avatar
0
Fill in the blanks to copy the user object to the new user object by destructuring the name and age properties. Pass the value 9999 for the id property. Answer:- It's really simple. If you want to copy info from user you have to pass that in blank. For example : const user = { name: 'David', age: 28, id: 1234 }; let newUser = Object.assign({}, {name, age} = user, {id : 9999}); console.log(newUser.name);
12th Jun 2020, 5:30 AM
Shailesh Kumar meena
Shailesh Kumar meena - avatar
0
its very easy const user = { name: 'David', age: 28, id: 1234 }; let newUser = Object.assign({}, {name, age } = user , { id : 9999}); console.log(newUser);
27th Aug 2020, 12:25 PM
AKHILA BUDYALA
0
add, sage, port
23rd Nov 2020, 8:01 AM
Javier Garcia Ortiz
Javier Garcia Ortiz - avatar
0
const user = { name: 'David', age: 28, id: 1234 }; let newUser = Object.assign({}, {name, age } = user , { id : 9999}); console.log(newUser);
2nd Dec 2020, 2:29 AM
Stiffler Bernard Awuah
Stiffler Bernard Awuah - avatar
0
const user = { name: 'David', age: 28, id: 1234 }; let newUser = Object.assign({}, {name, age } = user , { id : 9999}); console.log(newUser);
3rd Dec 2020, 8:08 PM
El Maslohi Hassan
0
const user = { name: 'David', age: 28, id: 1234}; let newUser = Object.assign({}, {name, age } = user , { id : 9999}); console.log(newUser); > Object { name: "David", age: 28, id: 9999 }
17th Dec 2020, 8:46 PM
Turikumana Isaie
Turikumana Isaie - avatar
0
Fill in the blanks to copy the user object to the newUser object by destructuring the name and age properties. Pass the value 9999 for the id property. const user = { name: 'David', age: 28, id: 1234 }; let newUser = Object.assign({}, {name, age } = user , { id : 9999}); console.log(newUser);
10th Mar 2023, 7:56 PM
Krishn Kant Sharma
Krishn Kant Sharma - avatar