The typeof
operator returns a string indicating the type of the unevaluated operand. It does work on execution time, so there is no TypeScript at this point. And there is no array type in JavaScript, as arrays are objects. You can read on mdn for more about JavaScript types.
Arrays exist only while writing code with your linter and on compilation time with your compilator as it's a TypeScript only type. You can use Array.isArray()
to test if someField
is an array on execution time, like so as an example:
console.log(Array.isArray(someField))
It's to know that there is a typeof specific to TypeScript that's different from the above one, that can be used in type definition, like so:
let s = "hello";
let n: typeof s;