1
00:00:00,540 --> 00:00:02,240
Hello and welcome.

2
00:00:02,340 --> 00:00:12,240
In this video I will introduce you to some javascript data types in programming in general and also

3
00:00:12,240 --> 00:00:22,800
in JavaScript the data types basically refers to the classification that specifies the type of value

4
00:00:23,190 --> 00:00:27,660
that a variable has or stores.

5
00:00:27,660 --> 00:00:34,730
There are different types of data types in JavaScript.

6
00:00:34,740 --> 00:00:40,350
Here's a basic table with some basic javascript data types.

7
00:00:40,380 --> 00:00:43,640
So I'm going to start with the top one which is this string.

8
00:00:43,690 --> 00:00:50,910
This trend basically is a sequence of text that must be enclosed in quotes.

9
00:00:50,910 --> 00:00:56,440
You can use either single quotes or double quotes but you cannot mix the quotes.

10
00:00:56,670 --> 00:01:02,460
For example here you can declare a variable called my data and set it to this value.

11
00:01:02,460 --> 00:01:05,600
You can see I've got quotes around it.

12
00:01:05,880 --> 00:01:14,100
I've got my web console open so the way to access your WAP web console if you are on a Windows computer

13
00:01:14,670 --> 00:01:23,610
open up just Google home page and type in control shift and Jay on your keyboard o f 12 and that would

14
00:01:23,610 --> 00:01:32,730
give you access to the Web console if you are on a Mac you do command shift and J that would give you

15
00:01:32,730 --> 00:01:34,010
access to the console.

16
00:01:34,140 --> 00:01:41,760
So let's create a simple variable that will store a string data type so in my console.

17
00:01:41,760 --> 00:01:50,220
I'm going to create a new variable by typing in the keyword V A r and I'm going to call this variable

18
00:01:50,970 --> 00:01:56,260
my colors okay.

19
00:01:56,390 --> 00:02:03,320
And I'm going to give it a value gonna give this value or read.

20
00:02:06,260 --> 00:02:12,950
So that's a value you can see I've enclosed the value in quotes which means if a string data type A

21
00:02:12,950 --> 00:02:16,770
computer will recognize that as a string data type.

22
00:02:17,120 --> 00:02:25,730
So if I want to reference this variable all I need to do is call it by its name and age or just return

23
00:02:26,120 --> 00:02:27,530
the value read.

24
00:02:28,490 --> 00:02:34,670
So that's a simple example of how a string data type can be used.

25
00:02:34,820 --> 00:02:43,870
The next data type I want to mention is the number data type basically refers to any numerical value.

26
00:02:44,270 --> 00:02:54,020
And it does not need to have a quote around its value to let me illustrate by creating a simple variable

27
00:02:54,660 --> 00:02:57,330
or store in no data type.

28
00:02:57,380 --> 00:03:07,070
So I declare a simple variable by typing in the keyword var and I'll call this variable door

29
00:03:10,410 --> 00:03:17,090
Don number and I'll give it a value of 7.

30
00:03:18,290 --> 00:03:23,420
So this is known as a no data type.

31
00:03:23,420 --> 00:03:26,250
You can see it doesn't need ports around it.

32
00:03:26,330 --> 00:03:35,920
So if I want to reference that variable I just call it by its name Don number and it will return the

33
00:03:35,930 --> 00:03:40,310
value of seven the next data type.

34
00:03:40,310 --> 00:03:48,570
I want to mention it's called a boolean a boolean basically represents two values that one can be true.

35
00:03:48,590 --> 00:03:57,810
The other can be false and we're using boolean values no quotes required to illustrate a billion of

36
00:03:57,830 --> 00:03:58,260
value.

37
00:03:58,280 --> 00:04:00,740
I'm just going to compare two values.

38
00:04:00,740 --> 00:04:07,130
I'm going to say four is greater than three.

39
00:04:07,430 --> 00:04:17,050
That will return true and a five say three is greater than four.

40
00:04:17,420 --> 00:04:20,510
And that will return false.

41
00:04:20,540 --> 00:04:27,220
So that's basically how boolean value data types work the next day to type.

42
00:04:27,230 --> 00:04:38,390
I want to mention is called an array an array is a data structure that stores multiple values as one

43
00:04:38,570 --> 00:04:40,190
single reference.

44
00:04:40,190 --> 00:04:46,970
Basically what that means a variable can store only one value but with an array you can store multiple

45
00:04:46,970 --> 00:04:50,990
values as one single reference.

46
00:04:50,990 --> 00:04:53,990
You can see here I've got two values here.

47
00:04:54,110 --> 00:05:00,000
Ford and Toyota both I'm referencing it on the one variable called my cars.

48
00:05:00,440 --> 00:05:03,380
So let me show you a quick illustration.

49
00:05:03,410 --> 00:05:09,920
Inside the console someone should declare a variable called my cars

50
00:05:12,530 --> 00:05:21,430
and I'm going to set it to a course to and this is how you declare an array with square brackets and

51
00:05:21,430 --> 00:05:24,940
inside the square brackets is where you place the values.

52
00:05:24,940 --> 00:05:36,090
So let's say the first value I say it's a Ford and second value I say is a Toyota.

53
00:05:38,560 --> 00:05:45,150
When you are using a raise you separate each of the values with a comma.

54
00:05:45,340 --> 00:05:49,180
The only way you don't need a comma is the very last value.

55
00:05:49,180 --> 00:05:59,680
So this basically here is an array and the way you access the values in an array is via the index.

56
00:05:59,680 --> 00:06:04,360
So the way an array is for France is by the index.

57
00:06:04,390 --> 00:06:07,610
So this will be known as zero index.

58
00:06:07,630 --> 00:06:09,930
This will be one if you have several.

59
00:06:09,940 --> 00:06:16,060
You can have as many as possible inside the square brackets but you need to separate the values with

60
00:06:16,060 --> 00:06:17,050
a comma.

61
00:06:17,050 --> 00:06:21,350
And if they are on the string data type you enclose it in quotes.

62
00:06:21,340 --> 00:06:25,180
If they are not then you don't need to enclose it in quotes.

63
00:06:25,180 --> 00:06:28,680
So for example if I wanted to access value.

64
00:06:28,750 --> 00:06:37,300
Number one this is zero index zero which is Ford Hall I need to do is typing my cards

65
00:06:41,270 --> 00:06:48,150
and in lowercase type in my cars and then in square brackets.

66
00:06:48,440 --> 00:06:56,150
I type in value zero which will represent the index I'm trying to target and that should return.

67
00:06:56,150 --> 00:06:58,200
You can see it has returned Ford.

68
00:06:58,350 --> 00:06:59,390
So that's how you.

69
00:06:59,510 --> 00:07:07,020
If I had like 20 inside here I will reference it fiber index based Val number.

70
00:07:07,130 --> 00:07:12,920
So Ford the very first values that zero index to hit I would be index number one and so on so that's

71
00:07:12,920 --> 00:07:17,570
how you access the values in an array.

72
00:07:17,660 --> 00:07:24,230
So the key difference between an array and variable is that an array can store multiple values as one

73
00:07:24,230 --> 00:07:24,620
value.

74
00:07:25,310 --> 00:07:33,860
If you see here I got just got this variable called my colors and is only stored one value here I've

75
00:07:33,860 --> 00:07:41,610
got a variable called my car's only stores multiple values by reference as a single values core my car's

76
00:07:42,170 --> 00:07:49,340
next data type I want to quickly mention it's called the object everything in Javascript is basically

77
00:07:49,340 --> 00:07:49,950
an object.

78
00:07:49,970 --> 00:08:01,370
So all the examples I have shown so far they are basically objects can also represent JavaScript objects

79
00:08:01,580 --> 00:08:08,330
with curly braces as I've done here I've declared a variable called Person set the value to cause to

80
00:08:08,330 --> 00:08:17,570
the first name got John last name though so you can represent an object like this way as well but by

81
00:08:17,570 --> 00:08:19,970
using curly braces.

82
00:08:21,500 --> 00:08:29,870
So if I wanted to access this object here all I need to do is call the variable by its name and it will

83
00:08:29,870 --> 00:08:31,200
return the.

84
00:08:31,250 --> 00:08:38,770
You can see he's returned the first name as John last name as do another data type.

85
00:08:38,840 --> 00:08:40,570
I want to introduce you to court.

86
00:08:40,610 --> 00:08:50,150
No you may come across this in your learning with JavaScript and basically in no data type is something

87
00:08:50,150 --> 00:08:52,690
that does not exist.

88
00:08:52,730 --> 00:09:03,440
You can also use the normal data type to empty the value of a variable and a normal is also an Object

89
00:09:03,710 --> 00:09:12,920
data type so you can see here got a variable here called Door Number and with a value of 7 so I can

90
00:09:13,130 --> 00:09:23,000
empty that value by just typing in the name of the variable which is number and set in the value to

91
00:09:24,320 --> 00:09:35,150
know and that will empty the current data it stores if I call these variable codon door number now it

92
00:09:35,150 --> 00:09:41,250
will come back saying no because I've emptied out the whatever it was storing.

93
00:09:41,270 --> 00:09:41,880
Okay.

94
00:09:42,110 --> 00:09:45,430
So a null data type means basically nothing.

95
00:09:45,440 --> 00:09:50,020
He doesn't store anything doesn't lock in in the final data type.

96
00:09:50,030 --> 00:09:56,710
I want to talk about is called undefined undefined is similar to No.

97
00:09:56,780 --> 00:10:06,020
The only difference is that the different data type on defined is undefined while in no data type is

98
00:10:06,020 --> 00:10:14,260
also an object data type or if you declare a variable you don't give it a value that will become undefined.

99
00:10:14,260 --> 00:10:20,000
For example if I call me and say variable suites

100
00:10:22,840 --> 00:10:25,030
and I don't give it any value.

101
00:10:26,500 --> 00:10:32,020
That would become undefined if I tried to call it by its name.

102
00:10:32,040 --> 00:10:33,730
It would come back undefined.

103
00:10:34,000 --> 00:10:39,570
So that's a key difference key difference between a normal and undefined.

104
00:10:39,570 --> 00:10:44,020
Is that undefined is not an object data type.

105
00:10:44,110 --> 00:10:55,750
While normal is an object data type so that's basically it for this video on javascript data types.

106
00:10:55,750 --> 00:10:57,010
Thanks for watching.

107
00:10:57,010 --> 00:10:57,790
Bye for now.
