在打字稿类型数组 - 就是数组℃之间的差异;美孚&GT;与富[]? [英] Typed arrays in TypeScript - what is the difference between Array<Foo> and Foo[]?
本文介绍了在打字稿类型数组 - 就是数组℃之间的差异;美孚&GT;与富[]?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在打字稿我有一个类富
class Foo {}
我想富的实例数组。之间有什么
I want array of instances of Foo. What is the difference between
var foos : Array<Foo>;
和
var foos : Foo[];
在我看来,这两个定义给定类型的实例数组,有什么不同呢?
It seems to me that both define array of instances of given type, is there any difference at all?
编辑:什么是这些结构的名字?我如何正确地指给他们吗?
What are the names of these constructs? How do I correctly refer to them?
推荐答案
他们都是类型标注相同的,所以你可以使用任何你preFER。
They are both identical as type annotations, so you can use whichever you prefer.
由于添加泛型数组语法只提供了。
The Array syntax has only been available since generics were added.
这篇关于在打字稿类型数组 - 就是数组℃之间的差异;美孚&GT;与富[]?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文