Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Compare typeof (returns a string for primitive types and "object"/"function" for references) with instanceof (walks the prototype chain). Highlight the classic gotchas: typeof null returns "object", typeof [] returns "object", and show Array.isArray as the reliable array check.
typeof operates on the internal type tag of a value (with the null bug being a legacy spec issue), while instanceof relies on the prototype chain. Neither alone covers all cases, so combining them or using Array.isArray is necessary.
Updated Mar 2026