Which is the difference between declaring a field as Array<any>
and Array<Object>
.
Is there some extra collection tools in typescript?
An Object
in TypeScript is the same thing as in JavaScript.
The difference is that any
accepts primitives as well: a number
is not an object, unless boxed to a Number
.
So while an Array<any>
can contain primitives, an Array<Object>
can't.
TL;DR: don't use Object
.
Source: TypeScript's Do's and Don'ts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With