Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In TypeScript I have a class Foo

class Foo {}

I want array of instances of Foo. What is the difference between

var foos : Array<Foo>;

and

var foos : Foo[];

It seems to me that both define array of instances of given type, is there any difference at all?

EDIT: What are the names of these constructs? How do I correctly refer to them?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
681 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...