對象字面量
const obj = {} // {} 表示字面量
屬性增強寫法
// ES5
const name = 'kobe';
const age = 18;
const height = 1.88;
const obj = {
name: name,
age: age,
height: height
}
// ES6
const name = 'kobe';
const age = 18;
const height = 1.88;
const obj = {
name,
age,
height
}
函數增強寫法
// ES5
const obj = {
get: function() {
},
set: function() {
}
}
// ES6
const obj = {
get() {
},
set() {
}
}