今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
The beginning: Unshift and shift data
- A queue functions similarly to a stack. But this data structure operates under the first in, first out rule. In order to add or remove data from a queue, we will use the array methods, unshift and shift. Unshift and shift operate almost identically to push and pop except that the data is added and removed from the beginning of the array versus the end. The array method unshift allows us to add one or more items to the beginning of an array. Here we will use our sports array again, but this time we're going to pass baseball to unshift. As we can see, baseball was added to the beginning of the sports array. The unshift array method takes a single argument, which is whatever you'd like to add to your existing array. It can be one or more elements. Unshift returns the length property for the newly changed array. This is the same behavior as the array method push. Now let's move on to shift. When this array method is applied…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。