- Web Development with MongoDB and Node(Third Edition)
- Bruno Joseph D'mello Mithun Satheesh Jason Krol
- 151字
- 2021-07-08 10:32:44
Understanding arrays
Arrays work the same way in JavaScript as they do in pretty much any other language. They are zero indexed, and you can declare a variable as an empty array or a pre-populated array. You can manipulate the items in an array, and arrays are not fixed in length:
var favFoods = ['pizza', 'cheeseburgers', 'french fries']; var stuff = []; // empty array var moreStuff = new Array(); // empty array var firstFood = favFoods[0]; // => pizza
// array functions: favFoods.push('salad'); // add new item
// => ['pizza', 'cheeseburgers', 'french fries', 'salad'] favFoods.pop(); // remove the last item // => ['pizza', 'cheeseburgers', 'french fries'] var first = favFoods.shift(); // remove the first item // => first = 'pizza'; // => favFoods = ['cheeseburgers', 'french fries']
To be more precise, you can consider arrays as extended child classes of the base Object class with extra implementations of Array functions.
推薦閱讀
- Extending Jenkins
- 微服務設計(第2版)
- INSTANT OpenCV Starter
- Windows系統管理與服務配置
- Mastering QGIS
- INSTANT CakePHP Starter
- Oracle BAM 11gR1 Handbook
- Mathematica Data Analysis
- 低代碼平臺開發實踐:基于React
- 新一代SDN:VMware NSX 網絡原理與實踐
- Spring技術內幕:深入解析Spring架構與設計原理(第2版)
- SQL Server 入門很輕松(微課超值版)
- Python數據科學實踐指南
- ASP.NET Core and Angular 2
- 虛擬現實:引領未來的人機交互革命