So far we’ve looked at
string arrays, but we could also have arrays that only contain
boolean). In fact, we can make arrays of any type whatsoever. We can also declare multidimensional arrays: arrays of arrays (of some type).
let arr: string = [['str1', 'str2'], ['more', 'strings']];
Think of the
string above as short for
(string), that is, an array where every element has type
string. We’ll explore more complex array types in later lessons.
The empty array (
) is compatible with any array type:
let names: string = ; // No type errors. let numbers: number = ; // No type errors. names.push('Isabella'); numbers.push(30);
Please provide type annotations for all the arrays provided in the
// Multidimensional arrays: section.