javascript - javascript/typescript 中的对象返回类型
问题描述
在Angular Tour of Heroes turorial 中,我不明白这种对象返回方式。
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
}
这是什么意思return {'heroes': heroes}
?什么叫这种语法?
解决方案
这是什么意思
{'heroes': heroes}
?
是的。
什么叫这种语法?
对象属性值简写
推荐阅读
- anylogic - Anylogic行人在特定时间到达
- c# - System.ArgumentNullException:值不能在 System.Linq.Enumerable.Any 为空
- c++ - 虚幻引擎和 Clion(无法获取编译器信息)
- css - 在类星体中设置不覆盖卡片的背景图像
- assembly - 如何比较汇编中的两个字符串?
- python - python关键字匹配(关键字列表-列)
- git - Gitlab SSH https 不同内容
- javascript - 如何在“交互式 IDE 代码课程”中查看答案
- php - 如何选择带有额外条件sql的重复行
- javascript - Mocha Chai - Confirm Body 中有一个“名称”属性