# Data Types — JavaScript

Source: https://www.geekswithgeeks.com/en/javascript/js-data-types

> Primitives, objects, and how to check a type.

## Primitive types

`number`, `string`, `boolean`, `undefined`, `null`, `symbol`, and `bigint` — seven primitives. Everything else is an `object`.

## typeof operator

`typeof` reports a value's type at runtime — handy for quick checks.

```js
console.log(typeof 42);          // "number"
console.log(typeof "hi");        // "string"
console.log(typeof true);        // "boolean"
console.log(typeof undefined);   // "undefined"
console.log(typeof {});          // "object"
console.log(typeof null);        // "object" (a famous quirk)
```

## null vs undefined

`undefined` means a variable was declared but never assigned. `null` is an intentional "no value" you assign yourself.

**Quiz:** What does `typeof null` return?

- [ ] "null"
- [x] "object"
- [ ] "undefined"

*Answer:* "object". It's a long-standing JS bug kept for backward compatibility.
