ES6对象简写

ES6对象简写:

var name = "test", age = 18, sex = "male";
var obj = {name: name, age: age, sex: sex};
<==>
var obj = {name, age, sex}

var obj = {
method: function() {
console.log("method");
}
}
<==>
var obj = {
method() {
console.log("method");
}
}

你可能感兴趣的:(ES6对象简写)