1
00:00:00,730 --> 00:00:06,120
In the first video on Javascript primitives when we talked about the five basic data types which are

2
00:00:06,120 --> 00:00:14,250
string number Puli an undefined No we kind of lumped non undefined together at the end and I mentioned

3
00:00:14,250 --> 00:00:17,580
that we would cover them in more detail in a future video.

4
00:00:17,580 --> 00:00:18,810
So that's what we're going to do here.

5
00:00:18,930 --> 00:00:23,940
And it's still going to be a pretty quick video because there's actually not very much to know and undefined

6
00:00:23,940 --> 00:00:24,600
.

7
00:00:24,890 --> 00:00:32,080
They are both just values that a variable can be set to and they both mean nothingness in a sense.

8
00:00:32,250 --> 00:00:33,810
But there's a big difference between them.

9
00:00:33,960 --> 00:00:36,700
So the code I have here illustrates that difference.

10
00:00:37,020 --> 00:00:38,830
So let's start with undefined.

11
00:00:39,240 --> 00:00:45,190
So if we declare a variable like we have here var age but we never said it to something.

12
00:00:45,510 --> 00:00:50,490
So it's declared but not initialized to a value it's considered undefined.

13
00:00:50,730 --> 00:00:52,110
So I'll show you what that means.

14
00:00:52,130 --> 00:01:01,200
It looks like if I just run that code var age and I never set it to a value I tell javascript make some

15
00:01:01,200 --> 00:01:06,840
space for something called age but we never store anything in there.

16
00:01:07,020 --> 00:01:15,870
If I asked for age back it tells me undefined and I want to contrast that with if I just ask for something

17
00:01:15,870 --> 00:01:17,370
that doesn't exist at all.

18
00:01:17,370 --> 00:01:20,090
Like color.

19
00:01:20,100 --> 00:01:23,550
It gives me an actual error message versus age.

20
00:01:23,550 --> 00:01:25,000
It knows about age.

21
00:01:25,080 --> 00:01:29,810
It just doesn't know anything inside of age and then no.

22
00:01:30,180 --> 00:01:36,420
It's another way of expressing nothingness but it's very different because no means something is explicitly

23
00:01:36,420 --> 00:01:42,600
empty or explicitly nothingness versus undefined which just means that something doesn't have a value

24
00:01:42,750 --> 00:01:43,830
yet.

25
00:01:43,860 --> 00:01:48,170
So in this example here I'm showing a case where you might use NULL.

26
00:01:48,360 --> 00:01:54,150
So if we had a current player variable we were making a game and it's set to be a string of the name

27
00:01:54,150 --> 00:01:55,430
of the current player.

28
00:01:55,740 --> 00:02:01,230
If that player then dies there's a game over we could set current player to be No.

29
00:02:01,410 --> 00:02:08,280
To make it explicitly clear that there is no current player so direct this appear no undefined are similar

30
00:02:08,510 --> 00:02:11,530
in that they both mean nothingness.

31
00:02:11,670 --> 00:02:18,480
But there's a big difference in that no means explicitly nothing versus undefined means that something

32
00:02:18,480 --> 00:02:21,500
is empty or doesn't have a value yet.

33
00:02:21,960 --> 00:02:23,890
So that really doesn't sound like a big difference.

34
00:02:23,970 --> 00:02:29,130
But as we go throughout this course you'll run into an undefined and we'll see the difference and it

35
00:02:29,130 --> 00:02:30,800
will make a lot more sense as we keep going.

36
00:02:30,870 --> 00:02:32,970
But I just want you to be aware that there is a difference
