Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
JAVASCRIPT DATA / CHAPTER 02 / Learn / LESSON 02
Second class. An array can grow. .push(x) appends at the end.
Interesting: const amounts = [...] forbids reassigning the name amounts, but the array contents can still change. amounts.push(15) is fine; amounts = [] usually is not.
Mini example:
const list = [1, 2]; list.push(3); console.log(list.length);
Common mistake: using let and replacing the whole array instead of push; or forgetting that push returns the new length.
push appends. const still allows changing contents.
DATA STANDBY
›