Transcript from the "Kinds of Emptiness" Lesson
>> Kyle Simpson: A quick note on undefined versus undeclared. This is often confused. And it's confused because developers, quite naturally, think of these words as sort of synonyms. They seem like they mean kind of almost the same thing. And in English, that's probably true. But in programming, it's entirely not true.
[00:01:04] And undefined means there's definitely a variable, and at the moment, it has no value.
>> Kyle Simpson: Very different things.
>> Kyle Simpson: The type of operator is the only operator in existence that is able to reference a thing that doesn't exist and not throw an error.
>> Kyle Simpson: Now, undefined and undeclared, we can fairly straightforwardly sift those out.
[00:01:28] But there's another concept of emptiness in the language that was introduced with, essentially, ES6. And the best way to describe this is uninitialized. Another way of referring to this particular condition that a variable can be in is called the TDZ, the temporal dead zone. We're gonna get much more into this in our next unit of discussion when we talk about scopes.
[00:01:53] We're gonna talk about where this thing comes from. But essentially, the idea is that certain variables, like block scope ones, don't get initialized. They never initially get set to undefined. When something is in an uninitialized state, it is off-limits. You're not allowed to touch it in any way, shape or form, or you'll get an error, and the error you get is the TDZ error.
[00:02:15] So it's yet another concept that we have of this emptiness. We can have a variable that's never been initialized. We can have a variable that's been initialized that is undefined. Or we can have a variable that was never even created, and then it's undeclared. Three different concepts that we need to wrap our brains around.