This tutorial talks about object literal syntax in ES6/ES2015
Before ES6, Object literals are defined with key and value pairs
function addEmployee=(id,name){
return {
id:id,
name:name
}
}
console.log(addEmployee(1,"Ram")) // {id:1,name:"ram"}
This function passed with id, name values and return an object. Here object keys needs to pass and redundent to pass.
with ES6, These are ignored.
ES6 Object Literal Shorthand
No need of passing object keys to return.
function addEmployee=(id,name){
return {
id,
name
}
}
console.log(addEmployee(1,"Ram")) // {id:1,name:"ram"}