Hello and welcome home.
This video I'll be introducing you to Javascript perris.
What is Harry and Harry is basically a structure that allows you to store multiple values in one single
reference.
Basically what that means is that it stores multiple values in a single variable.
So I am very special variable which can hold more than one value at a time in comparison to a variable
that can only hold one value at a time.
An example of an array is this here for example create an array code.
My data an easy cause to assign the values.
You can tell is an array because the values of an array are enclosed in square brackets.
Also you can have different data types in an array.
In this example here I have a number and string data type values in salary.
So let's create a simple Harry using the whip console to create a.
You have to create the variable first so you just type in V are to create or define the variable to
a space followed by the name you want to call a variable and when the call mine my my data then use
it equals to sign to create the array.
I use the open square brackets and you add the values or the elements in the hurry.
You can mix datatypes in my example here.
I'm going to mix the date and time with this string and or so in no sample a number and a shrink.
I'm going to add another number and then I'll add another string.
When you are using a string don't forget to include them in quotes and where you are using the phrase
you separate each of the elements in the array by comma.
You can see a comma here and comma here only the last value or element that does not require com.
So now that we've created an array to call the aerie we just need to call it by his name which is my
data and it would display the information.
The information here tells you that we've got an array of four elements which is one two three four
and it gives you the values.
If I expand this he will see all these figures here.
They're known as index the way you access the elements in an array is via their index.
So the very first element of value has indexed zero.
The next one will have index 1 and so on you can see here index 0 belongs to 7 index 1 belongs to John
indexed to plunks the 70 index 3 belongs with Jane and so on till you hear the length of the Harry is
four.
Because it has four elements or values inside the rig.
So if I wanted to ask says Jane what the way we do that would be my data
and then square brackets and I type in three because that's the index for Jane press enter and give
me the value of Jane because Jane has an index of three so you can see here from the index.
So always remember that where you're trying to access the values in an array you have to access them
using the index and index starts from zero points.
When you work with arrays it is easy to remove elements and also add new elements to an array using
a process called popin and pushing.
If you want to add elements you use a method called push in to add an element.
And if you want to remove you use a method called popin so poplin will remove pushing will add an element
to an array.
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
called My data.
And then you add a dot and type in push and then imperent this is you specify the value you're trying
to push into the every sphere.
I'm trying to add in number 10 into the Harry and I press Enter so we can see it now.
Is now showing that the tree has five values.
So if I want to call this every game called my data it will now show that the length is 5 C because
I have now added a new element which is this number 10 here.
So if I expand that you can see the index in new index for which is number 10.
If I wanted to remove an element from Harry.
Okay so I can do that using the pop method that pop meant it will remove the value of just less from
all the value I have just had it so I type in my data.
Pop and this will remove the very last value I have just added.
He can see here tells me 10 has been removed so far now this Harry now is should go back to your original
value which is a narey of 4.
See here this is the original letter.
That's basically how you can add more an element from an array.
So this concludes this brief introduction to Chama script arrays.
There are other types of arrays and there are so many things you can do using have a script read.
This is just an introduction to what an array is.
Thank you for watching and by phone.