While going through the Tour of Heroes tutorial for Angular, I found this method of returning an object to be confusing.
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}; // <-- exactly what does this line do?
}
Wouldn't it make more sense to write return {'heroes': heroes}
?
What is the terminology for this type of syntax?