Check out a free preview of the full Getting Started with JavaScript, v2 course

The "Undefined vs Undeclared" Lesson is part of the full, Getting Started with JavaScript, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Kyle explains how the two concepts around emptiness in JavaScript, undefined and undeclared, differ.

Preview
Close

Transcript from the "Undefined vs Undeclared" Lesson

[00:00:00]
>> Kyle Simpson: Let's talk about two very special concepts around emptiness that come into play heavily when we're talking about scope. I just mentioned the idea of a variable never having been declared, the topic variable in that previous slide. It's never been declared. That is the state of undeclared, and a lot of people think the word undefined is the same concept.

[00:00:22]
That being undefined or being undeclared are basically the same thing. They're very distinctly different. Specifically in a program something that is undefined is a variable that has been declared, but it doesn't have a value. And then a variable that is undeclared is one that was never declared anywhere.

[00:00:41]
We just start trying to reference it. And the JavaScript engine has no idea where that is.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now