繁体   English   中英

Object 在 javascript/typescript 中返回类型

[英]Object return type in javascript/typescript

在angular 英雄之旅教程中,我不明白object这种返回方式。

 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}

是的。

这种语法叫什么?

Object 属性值简写

https://alligator.io/js/object-property-shorthand-es6/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM