获取值的函数
1 let user = { 2 name: "John", 3 surname: "Smith", 4 5 get fullName() { 6 return `${this.name} ${this.surname}`; 7 } 8 }; 9 10 alert(user.fullName); // John Smith
属性名:fullName
属性特性:get
获取值的函数
1 let user = { 2 name: "John", 3 surname: "Smith", 4 5 get fullName() { 6 return `${this.name} ${this.surname}`; 7 } 8 }; 9 10 alert(user.fullName); // John Smith
属性名:fullName
属性特性:get