Note typeof null === "object" is a historic bug that will never be fixed. Use value === null for null checks. Arrays report as "object" -- use Array.isArray() instead.
Frequently asked questions
How does Python handle type checking?
This task is covered in 2 stacks on this page: Python, JavaScript. The "Type Checking at Runtime" snippet in Python uses `type(obj)`.
Which code does the Python example use?
The "Type Checking at Runtime" snippet uses `type(obj)`, from the Variables & Types section of the Python cheat sheet.
Which stacks cover "type checking" on this page?
Python, JavaScript. Together they hold 3 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Type Checking at Runtime": Prefer isinstance() over type() == because isinstance handles subclasses correctly. The second arg can be a tuple of types.