Splitting arrays into X elements and “the rest”
When a feature calls for the first five photos from a list and a link that says “27 more photos”, we can split the list of photos into these two blocks.
Read fire tipBy wrapping the variables in a console.log
in curly brackets, it logs an object that uses the names of the variables as keys. That makes it easier to see what each value represents.
const apples = 6
const children = 3
const cars = 1
console.log(apples, children, cars)
// ⇒ "6, 3, 1"
//
// Wait, what does the `3` mean again?
console.log({ apples, children, cars })
// ⇒ "{ apples: 6, children: 3, cars: 1 }"
//
// The variables’ names act as labels here.
When a feature calls for the first five photos from a list and a link that says “27 more photos”, we can split the list of photos into these two blocks.
Read fire tip