var student={
student1:{
name:"John",
}
}
var student2={
name:"Doe"
}
Resultamt object should contain both student object with their object's name Like this:-
students={
student1={name:"John"},
student2={name:"Doe"}
}
You can use object spread to solve this.
eg
let student = { student1: { name: "John", }, }; let student2 = { name: "Doe", }; let students = {...student, student2, }; console.log(students);
Using spread operation you can combine them.
const students = {
...student1,
...student2
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.