1
00:00:00,600 --> 00:00:02,130
Hello and welcome home.

2
00:00:02,130 --> 00:00:08,040
This video I'll be introducing you to Javascript perris.

3
00:00:08,610 --> 00:00:21,870
What is Harry and Harry is basically a structure that allows you to store multiple values in one single

4
00:00:22,170 --> 00:00:23,390
reference.

5
00:00:23,690 --> 00:00:32,950
Basically what that means is that it stores multiple values in a single variable.

6
00:00:33,600 --> 00:00:43,620
So I am very special variable which can hold more than one value at a time in comparison to a variable

7
00:00:43,950 --> 00:00:48,410
that can only hold one value at a time.

8
00:00:48,510 --> 00:00:54,750
An example of an array is this here for example create an array code.

9
00:00:54,750 --> 00:01:00,220
My data an easy cause to assign the values.

10
00:01:00,420 --> 00:01:08,820
You can tell is an array because the values of an array are enclosed in square brackets.

11
00:01:09,150 --> 00:01:13,490
Also you can have different data types in an array.

12
00:01:13,530 --> 00:01:21,610
In this example here I have a number and string data type values in salary.

13
00:01:22,170 --> 00:01:31,360
So let's create a simple Harry using the whip console to create a.

14
00:01:31,530 --> 00:01:40,310
You have to create the variable first so you just type in V are to create or define the variable to

15
00:01:40,320 --> 00:01:50,250
a space followed by the name you want to call a variable and when the call mine my my data then use

16
00:01:50,250 --> 00:01:54,890
it equals to sign to create the array.

17
00:01:55,260 --> 00:02:03,090
I use the open square brackets and you add the values or the elements in the hurry.

18
00:02:03,330 --> 00:02:07,010
You can mix datatypes in my example here.

19
00:02:07,190 --> 00:02:18,080
I'm going to mix the date and time with this string and or so in no sample a number and a shrink.

20
00:02:18,570 --> 00:02:26,480
I'm going to add another number and then I'll add another string.

21
00:02:26,970 --> 00:02:35,490
When you are using a string don't forget to include them in quotes and where you are using the phrase

22
00:02:36,150 --> 00:02:41,480
you separate each of the elements in the array by comma.

23
00:02:41,490 --> 00:02:51,670
You can see a comma here and comma here only the last value or element that does not require com.

24
00:02:52,920 --> 00:03:00,480
So now that we've created an array to call the aerie we just need to call it by his name which is my

25
00:03:00,480 --> 00:03:05,750
data and it would display the information.

26
00:03:06,030 --> 00:03:14,550
The information here tells you that we've got an array of four elements which is one two three four

27
00:03:15,300 --> 00:03:18,310
and it gives you the values.

28
00:03:18,340 --> 00:03:23,510
If I expand this he will see all these figures here.

29
00:03:23,730 --> 00:03:31,390
They're known as index the way you access the elements in an array is via their index.

30
00:03:31,620 --> 00:03:36,320
So the very first element of value has indexed zero.

31
00:03:36,390 --> 00:03:44,850
The next one will have index 1 and so on you can see here index 0 belongs to 7 index 1 belongs to John

32
00:03:45,360 --> 00:03:53,880
indexed to plunks the 70 index 3 belongs with Jane and so on till you hear the length of the Harry is

33
00:03:53,880 --> 00:03:54,600
four.

34
00:03:54,750 --> 00:04:01,060
Because it has four elements or values inside the rig.

35
00:04:01,260 --> 00:04:09,150
So if I wanted to ask says Jane what the way we do that would be my data

36
00:04:11,900 --> 00:04:25,270
and then square brackets and I type in three because that's the index for Jane press enter and give

37
00:04:25,290 --> 00:04:32,010
me the value of Jane because Jane has an index of three so you can see here from the index.

38
00:04:32,220 --> 00:04:38,880
So always remember that where you're trying to access the values in an array you have to access them

39
00:04:39,060 --> 00:04:45,430
using the index and index starts from zero points.

40
00:04:45,900 --> 00:04:55,710
When you work with arrays it is easy to remove elements and also add new elements to an array using

41
00:04:55,770 --> 00:04:59,600
a process called popin and pushing.

42
00:05:00,110 --> 00:05:10,710
If you want to add elements you use a method called push in to add an element.

43
00:05:11,000 --> 00:05:21,050
And if you want to remove you use a method called popin so poplin will remove pushing will add an element

44
00:05:21,080 --> 00:05:22,570
to an array.

45
00:05:23,030 --> 00:05:32,580
So let's add an element to hiree and the way we do that we call the tree his name which is my case is

46
00:05:32,610 --> 00:05:36,150
called My data.

47
00:05:38,450 --> 00:05:48,800
And then you add a dot and type in push and then imperent this is you specify the value you're trying

48
00:05:48,800 --> 00:05:51,260
to push into the every sphere.

49
00:05:51,320 --> 00:05:59,420
I'm trying to add in number 10 into the Harry and I press Enter so we can see it now.

50
00:05:59,510 --> 00:06:04,380
Is now showing that the tree has five values.

51
00:06:04,610 --> 00:06:16,640
So if I want to call this every game called my data it will now show that the length is 5 C because

52
00:06:16,690 --> 00:06:21,170
I have now added a new element which is this number 10 here.

53
00:06:21,170 --> 00:06:29,090
So if I expand that you can see the index in new index for which is number 10.

54
00:06:29,180 --> 00:06:35,700
If I wanted to remove an element from Harry.

55
00:06:36,200 --> 00:06:48,290
Okay so I can do that using the pop method that pop meant it will remove the value of just less from

56
00:06:48,290 --> 00:06:53,380
all the value I have just had it so I type in my data.

57
00:06:59,240 --> 00:07:07,640
Pop and this will remove the very last value I have just added.

58
00:07:08,160 --> 00:07:16,420
He can see here tells me 10 has been removed so far now this Harry now is should go back to your original

59
00:07:16,420 --> 00:07:20,480
value which is a narey of 4.

60
00:07:20,640 --> 00:07:22,670
See here this is the original letter.

61
00:07:22,690 --> 00:07:28,760
That's basically how you can add more an element from an array.

62
00:07:29,020 --> 00:07:34,400
So this concludes this brief introduction to Chama script arrays.

63
00:07:34,420 --> 00:07:40,570
There are other types of arrays and there are so many things you can do using have a script read.

64
00:07:40,570 --> 00:07:45,940
This is just an introduction to what an array is.

65
00:07:45,940 --> 00:07:48,280
Thank you for watching and by phone.
