Sharing buttons:

hello everyone and welcome back Jean

Beltre here in this video we are going

to start creating an empty array and

appending or adding a value to it and

we'll be adding these values or element

one after the other so let us jump

straight in and start practicing so I'll

go back to my NetBeans IDE okay which is

right here and I've closed the file

which we this file here remember we

created this file arrays one so I've

closed it you can go ahead and close it

file right here and we are going to

create a second JavaScript file under

the same folder so you go to the site

root here right click go to new and

click javascript file and we're just

gonna call it empty array okay and I'll

go ahead and say finish so I'm gonna go

ahead and remove all the comments

generated by the IDE and I'll go ahead

and save all the change alright so now

what I want to do here is create a

variable and I just want to call it

first name so this is going to be an

array that is going to store the names

of some some people or some student so

we can just do this and by doing this we

are actually indicating okay we just put

in some empty square bracket that says

opening and closing square brackets

which basically means it's an array but

it is really empty as it is because

there is no element inside of it okay

now you can alternatively use the

constructor model which we looked at in

the discussion and that would be for

example last names and this time I'll

say new array so this is also okay and

acceptable both of these array variables

are valid arrays in JavaScript but like

I said we are going to to be adopting

the first one so I'll go ahead and

comment this or I can actually go ahead

and delete it but I'll just comment it

it would be ignored anyway and what I

want to do now is start adding values to

this range so I'll simply say first

names which is the name of the variable

and I'll put in those braces again and

then I'll put in the index number which

is at zero and then I will assign a

value and I can say for example gems

that's all now I can go ahead and do

this multiple times and he--exactly say

something like console Atta and then I

will continue and put in another value

and I can actually say something like


and I can continue again and again and

again and I can actually say something

like Blunden and I can actually add the

last one here and I can actually say

bond okay so what you've done is create

on line number one an empty array here

you can see of our first names which is

an empty array okay and you can tell

it's empty because of this and line

number three we started a pending or

adding element or values to it and all

these are string values as you can see

and at index 0 we have appended or

pallets are the value gems at index 1 we

have added the value console later at

index 2 terms 3 blundin and 4 bonds so

this is a valid JavaScript array with

five different elements so we have one

two three four five starting from index

0 to index 4 and if wanna print them out

it is basically the same way console dot

log and we can actually log first name

at position 4 ok which of course as you

may guess it's gonna print bond here ok

so we run and that prints bond and if we

change this to 0 that gives us the first


in the array and so forth which is gems

okay so that's really it's about

creating an empty array and adding

values to it one by one and so in the

next video we will start talking about

loops and how we can mix arrays and

loops together to have a more working

application thank you for watching