课程: JavaScript: Arrays

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

The end: Push and pop data

The end: Push and pop data

- [Instructor] Have you ever heard of the Last In, First Out roll? What about a stack? A stack is a data structure that holds a list of items and operates using the Last In, First Out roll. Think of a stack, like a stack of physical items, papers, books even pancakes. The array methods, push and pop, are how data is added and removed from stacks. At the start of my coding career, push was the first array method that I learned. I used it a lot in conjunction with for loops. And you may already be familiar with it as well. We're going to discuss, push and pop together, because they share a few things in common. Both of these array methods manipulate the length and contents of an array, by adding or removing data to and from the end of an array. The array method push, allows us to add one or more items to an existing array. Here we have an array of sports. If we pass football to the array method push, that is applied to…

内容