📅  最后修改于: 2022-03-11 15:02:05.030000             🧑  作者: Mango
// method 1
function nested(name , age , color){
this.name = name;
this.details = {
age : age,
color : color
}
}
let nestedObj = new nested( "Elroi" , 22 , "blue");
console.log(nestedObj)
// method 2
class Nested2{
constructor(name , age , color){
this.name = name;
this.details = {
age : age,
color : color
}
};
displayInfo(){
console.log(`${this.name} ${this.details.age} ${this.details.color} `)
}
}
let aaa = new Nested2("Ean" , 14 , "black");
aaa.displayInfo();