Comparative Analysis of shift and unshift examples in js
Today, I would like to share with you the relevant knowledge points about the comparative analysis of shift and unshift examples in js. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
1. Add unshift can accept = = add multiple items, but delete only one item by shift.
Arrays shift and unshfit provide a similar method of queue operation (First-In-First-Out first-in, first-out), adding or removing from the header.
2. Shift and unshfit will modify the original array, shift will return the item = = delete = =, and unshift will return the length of the array after = = add = =.
Example
/ / unshift is to add all var colors = new Array () to the header; / / create an array var count = colors.unshift ('red',' green'); / / ['red',' green'] these are all the contents of the article "Comparative Analysis of shift and unshift examples in js". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.