0

I'm in the middle of a typescript course. We're learning generics and the following example is shown

const hobbies: Array<string> = ['coding', 'eating']

Now before I learned to check an array of type using the following syntax

const hobbies: string[] = ['coding', 'eating']

Can anyone explain me what the difference is?

Miguel Stevens
  • 8,631
  • 18
  • 66
  • 125

1 Answers1

2

Those two mean the same thing. So i can see that as a useful example for introducing the concept of generics, since it takes a concept you're already familiar with (arrays) and shows another way it can be done. But generics can also be used in a broader range of contexts than just arrays.

Nicholas Tower
  • 72,740
  • 7
  • 86
  • 98