typeof on a value
typeof gives you back, as a string, the name of the type a value has at the moment the code runs.
typeof is an operator that goes before a value and produces a string: "string", "number", "boolean", "undefined", "object", "function", "bigint" or "symbol". It is evaluated while Node runs the program, so it looks at the real value, not at what the type checker believes.
That makes it useful for deciding what to do with a value of uncertain type: if you compare typeof x === "string", TypeScript understands that check too and narrows the type inside the if.
Two quirks to know: typeof null gives "object" (a historical mistake in the language) and arrays also give "object". In the course you see it from lesson 01.00, with console.log(typeof "Diego"), to find out what a value is.
Don't confuse it with typeof inside a type: that one is erased before Node runs the code. This one is regular JavaScript and stays.
Reach for it when: you need to know at runtime what kind of value you have, for example to check an `unknown` value before using it.
Examples
Common mistake
console.log(typeof null); console.log(typeof [1, 2]);
Why: You expected "null" and "array", but typeof answers "object" for both.
How to write it: For null compare value === null; for arrays use Array.isArray(value).
