1
00:00:00,850 --> 00:00:04,930
Let's get started with how we can create an array.

2
00:00:05,620 --> 00:00:14,770
I have already created a folder core areas and inside I have two files, my HTML and then my JavaScript

3
00:00:14,770 --> 00:00:15,430
file.

4
00:00:15,610 --> 00:00:24,400
So inside my HTML, I have a few lines of code with the edge two and here I have link app my JavaScript

5
00:00:24,400 --> 00:00:25,060
file.

6
00:00:25,420 --> 00:00:29,660
So now let's work inside the JavaScript file.

7
00:00:29,680 --> 00:00:33,070
So how can we create an array?

8
00:00:33,580 --> 00:00:37,190
We have two ways of creating an array.

9
00:00:37,210 --> 00:00:43,140
So the first method is called the using the new keyword.

10
00:00:43,150 --> 00:00:49,480
So the first method is called using the new key.

11
00:00:50,260 --> 00:00:50,890
Word.

12
00:00:52,350 --> 00:00:52,770
Is that so?

13
00:00:52,770 --> 00:00:53,490
Here you go.

14
00:00:53,490 --> 00:00:54,960
So context.

15
00:00:54,960 --> 00:01:06,510
And then the name of my array, I would name it as my array is equal to new and then my array so new

16
00:01:06,510 --> 00:01:09,030
and then array as that.

17
00:01:09,030 --> 00:01:14,490
So inside this I can put in any data I want to save.

18
00:01:14,880 --> 00:01:21,390
For the meantime, let's say that we are creating books array as we showed in the diagram.

19
00:01:21,390 --> 00:01:23,340
So my books are array.

20
00:01:23,340 --> 00:01:28,320
So inside here I can put a new book that I want.

21
00:01:28,620 --> 00:01:33,210
So here let's say that I want to save this book.

22
00:01:33,950 --> 00:01:36,290
The next one html book.

23
00:01:37,280 --> 00:01:40,790
The third one is going to be as no jazz book.

24
00:01:41,060 --> 00:01:41,690
Yes.

25
00:01:41,690 --> 00:01:46,810
So any time I reference books, I have this record.

26
00:01:46,820 --> 00:01:52,190
So let's check inside our console and then let's search for books.

27
00:01:53,390 --> 00:01:54,560
You see that?

28
00:01:54,620 --> 00:01:57,200
I have the books, Harry.

29
00:01:58,020 --> 00:01:58,710
Perfect.

30
00:01:58,710 --> 00:02:05,190
So another way how we can add record to the books is like this one.

31
00:02:05,280 --> 00:02:07,430
So let me comment out this.

32
00:02:07,440 --> 00:02:08,970
Let me copy this one.

33
00:02:08,970 --> 00:02:11,520
Let me comment out the first one.

34
00:02:11,520 --> 00:02:19,830
And now after this one, we have created a new array, an empty array with this in time.

35
00:02:19,830 --> 00:02:25,020
So this one will give me an empty array as that.

36
00:02:25,260 --> 00:02:33,000
So if I check inside my console, it could see that I have the square bracket, which is an array,

37
00:02:33,000 --> 00:02:35,400
meaning there is nothing inside.

38
00:02:35,760 --> 00:02:39,240
So let's see how we can add books into this empty array.

39
00:02:39,300 --> 00:02:43,980
So first of all, I want to add a book or the index zero.

40
00:02:44,010 --> 00:02:51,300
So I need to specify books and then my square bracket and then index zero.

41
00:02:51,330 --> 00:02:55,050
I want to save, let's say CSS into that.

42
00:02:55,320 --> 00:02:58,500
So, so behind the scene are the index zero.

43
00:02:58,530 --> 00:03:00,330
I have saved CSS book.

44
00:03:00,570 --> 00:03:03,270
So if I check my console for books.

45
00:03:06,160 --> 00:03:06,670
Let's see.

46
00:03:06,670 --> 00:03:11,680
You can see that I have CSIS in the first array.

47
00:03:11,920 --> 00:03:16,960
So the next is if I want to put the next record as books.

48
00:03:17,790 --> 00:03:19,400
And then square bracket.

49
00:03:19,410 --> 00:03:23,730
I want to put an index one, which is my HTML.

50
00:03:24,120 --> 00:03:30,420
So the same thing, if I sell four books, you can see that I have a HTML at index one.

51
00:03:30,510 --> 00:03:36,720
So I can go on and go on and go on and add as many books as I want.

52
00:03:36,750 --> 00:03:38,670
So here, index two.

53
00:03:38,700 --> 00:03:42,770
Then let me save Node.js also.

54
00:03:43,470 --> 00:03:44,190
Perfect.

55
00:03:44,880 --> 00:03:48,110
So let me check now I have that.

56
00:03:48,120 --> 00:03:49,740
That's the first method.

57
00:03:49,890 --> 00:03:54,630
So first we create and then we assign it record into it.

58
00:03:55,200 --> 00:03:59,850
Or we can quickly add the variables inside.

59
00:03:59,880 --> 00:04:01,560
Let me call this one as books.

60
00:04:01,560 --> 00:04:06,690
Two here, books, two books, two to write a name will not be conflict.

61
00:04:06,840 --> 00:04:08,340
So here one method.

62
00:04:08,340 --> 00:04:16,279
Whether you go by this way or declare the empty array and then add the record or declare the array.

63
00:04:16,290 --> 00:04:20,120
And on this part you can add in your record.

64
00:04:20,130 --> 00:04:23,280
That's the first method of creating an array.

65
00:04:23,520 --> 00:04:30,600
The second method for creating an array is using the array literal.

66
00:04:30,600 --> 00:04:36,270
So step number two or method two is using the array literal.

67
00:04:36,390 --> 00:04:38,670
And it goes like this the same thing.

68
00:04:38,700 --> 00:04:41,580
Let me name this one as books.

69
00:04:43,240 --> 00:04:46,540
Three so that they won't be conflict and all.

70
00:04:46,570 --> 00:04:50,350
What I need here is to bring my square bracket.

71
00:04:50,500 --> 00:04:51,700
And that is it.

72
00:04:51,700 --> 00:04:53,070
And that is it.

73
00:04:53,080 --> 00:04:55,420
So if I search for.

74
00:04:56,180 --> 00:04:56,660
Books.

75
00:04:56,660 --> 00:04:57,290
Three.

76
00:04:57,380 --> 00:04:59,540
We see that same as before.

77
00:04:59,570 --> 00:05:01,760
I have an empty array.

78
00:05:01,790 --> 00:05:09,140
So the same way I can add my record here as let me call this one as JavaScript.

79
00:05:10,990 --> 00:05:11,950
React.

80
00:05:14,230 --> 00:05:17,620
Express DJs and let's say redox.

81
00:05:18,100 --> 00:05:18,790
Yes.

82
00:05:18,790 --> 00:05:24,420
So if I search for books here with three, I have those records.

83
00:05:24,430 --> 00:05:29,530
So the same way I can also add the record in this way as before.

84
00:05:29,740 --> 00:05:34,510
So I can copy this one and then pass it here and comment on this one.

85
00:05:34,510 --> 00:05:42,010
So as before, let me remove here I can create an empty array and then here at record.

86
00:05:44,360 --> 00:05:44,860
Okay.

87
00:05:44,900 --> 00:05:52,040
So inside here I would take books and then the index zero.

88
00:05:52,070 --> 00:06:02,630
I want to save JavaScript file JavaScript book JS empty string here, JavaScript here and then books

89
00:06:02,630 --> 00:06:04,820
three at index zero.

90
00:06:05,720 --> 00:06:06,710
Index one.

91
00:06:06,710 --> 00:06:15,230
I want to save also my React book and books three at index.

92
00:06:15,800 --> 00:06:18,500
Index two I want to save.

93
00:06:18,560 --> 00:06:21,950
Let's say what book express js.

94
00:06:22,700 --> 00:06:23,710
Into that.

95
00:06:23,720 --> 00:06:29,180
So if I check for book three as before, I have it.

96
00:06:29,540 --> 00:06:30,290
Perfect.

97
00:06:30,290 --> 00:06:33,200
So let's have some facts about array.

98
00:06:33,200 --> 00:06:37,880
For array, we can save any kind of record.

99
00:06:38,120 --> 00:06:43,520
I mean, any kind of data type we can save into array.

100
00:06:43,550 --> 00:06:50,120
So here array can take any data.

101
00:06:50,820 --> 00:06:53,280
Type variable value.

102
00:06:54,700 --> 00:07:06,670
So comes let's see my array is equal to I can save string of say as before Let's say what string let's

103
00:07:06,670 --> 00:07:16,360
see food into that Yes, food is a string and then I can save boolean as let's say true into that.

104
00:07:16,360 --> 00:07:26,050
I can also save a number, say 20 into that I can also save null into that I can also save undefined

105
00:07:26,050 --> 00:07:30,940
into that consider how flexible this this array is.

106
00:07:30,940 --> 00:07:35,080
With one variable we can save multiple data types into it.

107
00:07:35,080 --> 00:07:36,370
That is awesome.

108
00:07:36,550 --> 00:07:39,040
But guys take note here.

109
00:07:39,580 --> 00:07:41,680
They add the name of array.

110
00:07:41,710 --> 00:07:44,590
Much depends what you are saving into it.

111
00:07:44,800 --> 00:07:49,660
So let's say that this array is about books and you are saving food.

112
00:07:49,660 --> 00:07:53,260
True 20 now and undefined weight.

113
00:07:53,530 --> 00:07:57,970
Where if I take this area, I'll ask myself what is this array?

114
00:07:57,970 --> 00:08:04,450
Or about the take away here is that array can store any data type.

115
00:08:04,660 --> 00:08:05,470
Perfect.

116
00:08:05,860 --> 00:08:08,620
All right, so that is it about the arrays.

117
00:08:08,650 --> 00:08:10,180
The next video.

118
00:08:10,210 --> 00:08:14,740
Let's see how we can access these arrays.

119
00:08:14,740 --> 00:08:19,750
Meaning after creating, how can I access these array?

120
00:08:19,780 --> 00:08:28,240
For example, if I actually place I don't want all this record give me only let's say react books or

121
00:08:28,240 --> 00:08:34,360
I mean JavaScript books or Node.js book, how are we going to do it?

122
00:08:34,360 --> 00:08:37,480
And that's what you call accessing arrays.

123
00:08:37,510 --> 00:08:40,330
Let's get into that in the next video.

