# JS Tip of the Day: typeof null === "object"

**URL:** <https://forum.kirupa.com/t/js-tip-of-the-day-typeof-null-object/643167>\
**Category:** web dev\
**Created:** [February 29, 2020, 1:49pm UTC](https://forum.kirupa.com/t/js-tip-of-the-day-typeof-null-object/643167 "2020-02-29T13:49:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [February 29, 2020, 1:49pm UTC](https://forum.kirupa.com/t/js-tip-of-the-day-typeof-null-object/643167/1 "2020-02-29T13:49:39Z")

</div>

**typeof null === "object"**  
Level: Beginner

The `typeof` operator is used to identify the basic type of a value in JavaScript. It can individually identify primitive types as well as recognize any other object type as being an object (with a special case for recognizing function objects as functions).

```javascript
console.log(typeof 1); // number
console.log(typeof "text"); // string
console.log(typeof undefined); // undefined
console.log(typeof {}); // object
console.log(typeof function () {}); // function
// ...

```

One particular quirk with `typeof` is that it will report the type of the value `null` as “object”.

```javascript
console.log(typeof null); // object

```

Because of this, if you’re using `typeof` to check for objects in your code, you may also want to include a check to make sure it is not also `null`. Otherwise, you might be accidentally using a `null` value as an object in a way that could cause errors.

```javascript
if (typeof someValue === "object" && someValue !== null) {
    // I don't object to the use of this object
}

```

More info:

- [typeof on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof)
