typescript typeof array code example
Example 1: typeof array
const array = [ 'this', 'is', 'an', 'array' ];
console.log(typeof array); //object
Example 2: get type of element of array typescript
const animals = ['cat', 'dog', 'mouse'] as const
type Animal = typeof animals[number]
// type Animal = 'cat' | 'dog' | 'mouse'