Reputation: 1011
During angular Tour of Heroes turorial, I didn't understand this way of object return.
createDb() {
const heroes = [
{ id: 11, name: 'Dr Nice' },
{ id: 12, name: 'Narco' },
{ id: 13, name: 'Bombasto' },
{ id: 14, name: 'Celeritas' },
{ id: 15, name: 'Magneta' },
{ id: 16, name: 'RubberMan' },
{ id: 17, name: 'Dynama' },
{ id: 18, name: 'Dr IQ' },
{ id: 19, name: 'Magma' },
{ id: 20, name: 'Tornado' }
];
return {heroes}; // <-- this line
}
Does it mean return {'heroes': heroes}
?
What is called this syntax ?
Upvotes: 0
Views: 49
Reputation: 3198
Does it mean
{'heroes': heroes}
?
Yes.
What is called this syntax ?
Object Property Value Shorthand
https://alligator.io/js/object-property-shorthand-es6/
Upvotes: 1