ES6 Shorthand Property Name
You can simplify the following code with ES6 shorthand property.
let id = 1, name = 'Toshimaru'
let obj = {
id: id,
name: name
}
// { id: 1, name: 'Toshimaru' }
let id = 1, name = 'Toshimaru'
let obj = {
id,
name
}
// { id: 1, name: 'Toshimaru' }
ES6 Shorthand Method Name
ES2015 introduces shorthand method names as well as shorthand property name.
You can simplify the following code with ES6 shorthand method name.
let obj = {
say: function(msg) {
console.log(msg)
}
}
obj.say("hello")
// hello
let obj = {
say(msg) {
console.log(msg)
}
}
obj.say("hello")
See Also
Merge arrays in ES6 way | Toshimaru’s Blog