Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Undefined | Data Types and Variables
Introduction to JavaScript

book
Undefined

What is Undefined

Undefined is also a data type in JavaScript just like the null. When a variable is created or declared without assigning any value to it, then the value of the variable will be set as undefined by default.

let age;
console.log(age);
12
let age; console.log(age);
copy
Task

Swipe to start coding

Declare a variable numberOfItems and assign the value of undefined to the variable and show the value of the variable.

Solution

let numberOfItems = undefined;
console.log(numberOfItems)

So, undefined variables can also be declared using the undefined keyword.

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 31

toggle bottom row
some-alt