Programming Basics: Intro to Arrays with Javascript

preview_player
Показать описание

Now things are getting interesting. This lesson is about arrays. We know how to set a variable equal to one value. What if we’ve got a bunch of values that go together? That’s where arrays come in.

Arrays are basically lists of different values, they can be a mix of strings, numbers, or boolean values, pretty much anything. The thing to remember is each value is associated with a number, but the first value isn’t one, we start with zero. So the array counts up or is indexed from zero to however many values you want to stick in it, there is no limit.

We use these numbers to put stuff into the array and pull stuff out. Let’s create an array like this:

Javascript uses square bracket to indicate an array. This array contains my codebabe stats, measurements of course, then my operating systems of choice, and favorite programming language.

You can see that it’s easy to mix integers and strings in an array. Array values get assigned numbers automatically. The thing to remember is that they start with zero. So my first measurement would be numbered zero.

But let’s say I wanted my measurements to be their own array. No problem. We can just wrap those numbers in square brackets, now we have an array within an array. An inception array.

If we log the array, go back and refresh the browser, we’ll see the values printed out, plus the values of the new array value within babe stats.

What if we wanted to grab something out of the measurements array now? We could do that by just adding another set of square brackets. Say you want to grab my waist, we just do console log babe stats zero and then one. Zero because the array values start with zero and one for the second value of the measurements array!

What if we wanted to add something to the array? To do this we need to use the javascript method "push", like this:

That would add another value to my babe stats. A method is another word for function in Object oriented programming lingo. You’ll have to watch another codebabes course on object oriented programming for that explanation. For now just take our word for it. If we log the array again we'll see the value that was pushed appended to the end.

Ok good work, you guys will get the hang of it. Next we’ll talk about loops, which go together with arrays like tantric sex and oil!
Рекомендации по теме
Комментарии
Автор

I love the values of array[0] and array[1]

subhambiswas
Автор

This is exactly what my teacher was lacking (u know what m talking about)

shubsodhi
Автор

I am mechanical engineering student but come here to learn computer science engineering

kunalsoam
Автор

Best course I've ever seen! Amazing concepts! kkk
Congratulations girls!

ps: next time the array could be your phone number

markmessa
Автор

hahahaha this channel is awesome, programming will be even more fun now XD

dwighsonPavion
Автор

hope i can start a decent job with skills from this video!

kostakosta
Автор

it's impossible to consetrate to the array ...   i see only (o)(o) 

fylactos
Автор

Ah when she says "Say you wanna grab my waist" when talking about arrays..thats when you just take your eyes away from the code totally....lol really this is a cool way to learn to code. Code Babes rock!!!

pvallabhai
Автор

this is best site youtube channel final i can understand. 

Krylon
Автор

U are soo good I want u to be my class teacher it's make me hard
(Working)

aryanchaudhary
Автор

I want to take these CodeBabes out for dinner so I can talk about web development  

ryana-
Автор

Great pretty tutorial, really helped....

mesrop
Автор

Can you please tell me what is the window on the left? A notepad or...?

Frag_Limit
Автор

I am failing love with this babe more than What a nice way to learn #Subscribed  

BacklogMehedi
Автор

I was bored to death learning JS from other sources, and am delighted to have stumbled on your channel! Love your irreverent and humorous approach to these dry topics, and you Codebabes make it all much easier on the eyes. Also glad you guys aren't intimidated by crybaby social justice warriors who are so quick to spring a self-righteous microboner and label this as "misogynistic". Kudos for taking their nonsensical circle-jerk in your stride! You know what's really misogynistic? Preventing girls from getting an education in places like Afghanistan and shit.
Argh hell, I'm a straight woman myself and I think Codebabes is a lot of fun! Of cos, I wouldn't complain if ya'll started hiring sexy men to teach me programming too haha. I've gone on long enough, hope you see this comment! Great job, looking forward to more content, stay renegade!

tooth
Автор

what the fap is this and why the fap am I here?!

ashyxt
Автор

oh my god you are amazing but "what is your name"?

americanmilkyway
Автор

I love how cringe it is to look at people teaching something they dont know a thing of

neilnair
Автор

Does she even know what she is talking about ? I can't focus either :) so bailing out of this channel.

goldilockszone
Автор

they are teachers or   girls  of  night

ahmedchakib