Suggest an editImprove this articleRefine the answer for “JS vs TS typeof”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**`typeof`** in JavaScript runs at runtime and returns a string naming the type (`"string"`, `"object"`), while in TypeScript `typeof` works at compile time and returns the type itself (for example, `number`). **Key point:** the TS variant does not execute any code - it is a purely TS concept for extracting types from values.Shown above the full answer for quick recall.Answer (EN)Image| Comparison | **JavaScript** | **TypeScript** | |---|---|---| | Scope | Runtime | Compile-time | | Returns | a string naming the type (`"string"`, `"object"`) | a type (for example, `number`, `{}`) | | Executes code? | Yes | No | | Used for | Checks in code (`if (typeof x === "string")`) | Extracting types from values | | JS equivalent | `Object.keys`, `typeof` | Nothing, this is a purely TS concept | | Example | `typeof 5 -> "number"` | `typeof 5 -> number` |For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.