- 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.
推薦閱讀
- JavaScript從入門到精通(微視頻精編版)
- oreilly精品圖書:軟件開發者路線圖叢書(共8冊)
- 零基礎學Java程序設計
- 深度學習:算法入門與Keras編程實踐
- 編譯系統透視:圖解編譯原理
- C程序設計案例教程
- Mastering RStudio:Develop,Communicate,and Collaborate with R
- Java Fundamentals
- Java Web從入門到精通(第3版)
- 機器學習微積分一本通(Python版)
- 奔跑吧 Linux內核
- .NET 4.0面向對象編程漫談:應用篇
- JavaEE架構與程序設計
- 和孩子一起學編程:用Scratch玩Minecraft我的世界
- Flask開發Web搜索引擎入門與實戰