---
title: "Discussion on \"Difference between null and undefined (explained in 5 seconds)\" | Hashnode"
description: "Discussion on \"Difference between null and undefined (explained in 5 seconds)\". null says\n\nthere is absolutely nothing.\n\nundefined says\n\nthere should be something but I have nothing.\n\nThis is why the following function returns undefined when the argument is passed nothing because it means the function needs something but it has ..."
url: "https://hashnode.com/posts/difference-between-null-and-undefined-explained-in-5-seconds/5fe0364db78ac62dff80e9e7"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Difference between null and undefined (explained in 5 seconds)](https://csdal.hashnode.dev/difference-between-null-and-undefined-explained-in-5-seconds?utm_source=hashnode&utm_medium=feed)

null says there is absolutely nothing. undefined says there should be something but I have nothing. This is why the following function returns undefined when the argument is passed nothing because it means the function needs something but it has ...

Dec 21, 2020 · 1 min read · csdal.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Cing Sian Dal](https://hashnode.com/@csdal)

@csdal

  
[View profile](https://hashnode.com/@csdal)

## Responses 1

Markdown supported · ⌘↵ to post

[Purvi Barot](https://hashnode.com/@purvi)

[Dec 22, 2020](https://hashnode.com/posts/difference-between-null-and-undefined-explained-in-5-seconds/5fe0364db78ac62dff80e9e7/comment/5fe17d600134f65eed0c9616)

**undefined** means a variable has been declared but has not yet been assigned a value.

```
var TestVar;
alert(TestVar); //shows undefined
alert(typeof TestVar); //shows undefined
```

**null** is an assignment value. It can be assigned to a variable as a representation of no value.

```
var TestVar = null;
alert(TestVar); //shows null
alert(typeof TestVar); //shows object
```

From the preceding examples, it is clear that undefined and null are two distinct types: **undefined** is a type itself (undefined) while **null** is an object.
