Viewers: in countries Watching now:
Finally, the course compares how code is written in several different languages, the libraries and frameworks that have grown around them, and the reasons to choose each one.
In this case, it would pop up the length of it being 24. I didn't have to go and count all the letters. The string itself actually knew what its length was, and we can use that same kind of format to find information about arrays. Let's say I use the shorthand format to create an array here with five elements ranging from position 0 through position 4. I could do something very similar that I did with the string and call myArray.length. In this case, it will pop up an alert box with the number 5. That's an important idea here.
You can create them yourself. We can also use the built-in functions like alert. In this case, I am passing in information into that function. Or I can call a function, passing in information that also returns a value. So functions are used all over the place. But we also have the idea of methods and they are very, very similar, but a method is a function that belongs to an object. So instead of calling it directly, we actually use the name of the object, then a dot, then the name of the method.
And when I say some method here with the opening and closing parentheses, it's very much like calling a function. But we have to say what does this method apply to, what I am doing it on, and we have seen this before. If we have a string variable, we can use the .toUpperCase method to actually convert that to uppercase. And we have several very useful ones with arrays. So I can create multiple arrays and then call the different methods on each array. So let's say I use the shorthand format here. I am creating a new array and just putting some random stuff in it.
We have useful little methods like .pop. If I call .pop on myArray it's going to take the last element, what's currently in there at oosition 4, and detach it and return that as a value. So we can pop something off the end of the array. Now the flip side of that, we also have .push. In this case I have to push a value on to the array and it will push it to the last element of the array. So these arrays are smart. They can tell us information, they have behavior. We can actually get to different pieces of them. And there is more that an array can do.
We jump into that Reference guide and what I will find is it breaks down all the different objects that are available, like array. I could go in and find some information about the array. it would give me a lot of descriptive stuff. But what I will find in the Table of Contents is there will be a section that says Properties, things like Length or Methods, and I could jump down to Methods and it would actually tell me, as I start to scroll down here, I have got the pop method which removes the last element from an array and returns that element. I have got the push method.
That will add one or more elements to the end of the array. I have got sort, I have got splice, and this is the way that you start navigating the language. You will find a reference guide for the language that you're working with and you start to explore the different pieces of the language as and when you need them. Don't try and memorize everything, because that's just not going to work. Just know where you can find the reference of the syntax. The ability to find what you need to in a reference guide is much more powerful than trying to memorize everything.
Find answers to the most frequently asked questions about Foundations of Programming: Fundamentals .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.