Introduction to JavaScript – Variables: Undefined

Introduction to JavaScript – Variables: Undefined

What happens if you create a variable, but don’t assign it a value?

JavaScript creates space for this variable in memory and sets it to undefined. Undefined is the fifth and final primitive data type. JavaScript assigns the undefined data type to variables that are not assigned a value.

Introduction to JavaScript – Variables: Undefined

let whatAmI;

OUTPUT: undefined

In the example above, we created the variable whatAmI without any value assigned to it. JavaScript creates the variable and sets it equal to the value undefined.

Related Videos: Related Videos.

Related Links:

JavaScript Glossary – Variables

My little pony learning game in VB.NET

Python Glossary

Learn about programming Classes and Objects in Python

Why do most sites use cookies?

Hello World Android app built with Android Studio

How to make a go-back button with PHP code?

Introduction to JavaScript – Control Flow: if/else Statements

Introduction to JavaScript – Control Flow: True and False values

Introduction to JavaScript – Data Types

Introduction to JavaScript – Properties

How to make a Go-Back Input button with inline JavaScript

Introduction to JavaScript – Variables: Review

Introduction to JavaScript – Review Types and Operators

Online JavaScript Compiler. Code on the go.

Introduction to JavaScript – Create a Variable: let

Introduction to JavaScript – Create a Variable: const

Why Python is the cooler programming language

Introduction to JavaScript – Variables: String Interpolation

W3Schools – Undefined

Connected through code, Choose Your Platform!

About the Author: Bernard Aybout

In the land of bytes and bits, a father of three sits, With a heart for tech and coding kits, in IT he never quits. At Magna's door, he took his stance, in Canada's wide expanse, At Karmax Heavy Stamping - Cosma's dance, he gave his career a chance. With a passion deep for teaching code, to the young minds he showed, The path where digital seeds are sowed, in critical thinking mode. But alas, not all was bright and fair, at Magna's lair, oh despair, Harassment, intimidation, a chilling air, made the workplace hard to bear. Management's maze and morale's dip, made our hero's spirit flip, In a demoralizing grip, his well-being began to slip. So he bid adieu to Magna's scene, from the division not so serene, Yet in tech, his interest keen, continues to inspire and convene.