freecoding.school100% FREE · NO SIGNUP
Closure CavesISSUE #18 of 61

arrays · ordered lists

LambdaVSThe Mutator
Lambda saysArrays are ordered, zero-indexed lists that can hold any mix of values.

[1, "two", true] — arrays hold anything, in order, accessed by index from 0. .length gives the count. They're objects under the hood (reference type) with a huge method library. Prefer the immutable, expressive methods (map/filter/reduce) over manual index loops where you can.

Power-ups you unlock

The Mutator attacks — common mistakes

Boss battleMake an array, read first and last by index, and log its length.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>const a=[10,20,30];
document.getElementById('o').textContent='first='+a[0]+' last='+a[a.length-1]+' len='+a.length;</script></body></html>
▶ Open the interactive comic issue
‹ Getters · Setters · AccessorsArray Methods · Push · Pop · Shift · Unshift ›