- 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.
推薦閱讀
- Git高手之路
- Magento 1.8 Development Cookbook
- Asynchronous Android Programming(Second Edition)
- C++從入門到精通(第5版)
- Python Machine Learning Blueprints:Intuitive data projects you can relate to
- Mastering Concurrency Programming with Java 9(Second Edition)
- Mastering PowerCLI
- 零基礎入門學習C語言:帶你學C帶你飛
- 前端程序員面試筆試真題與解析
- Python網絡運維自動化
- 邊做邊學深度強化學習:PyTorch程序設計實踐
- JSP程序設計與案例教程
- Python程序設計教程
- R語言編程:基于tidyverse
- C# 7.0核心技術指南(原書第7版)