Arrays and objects

Knowledge Videos

Short animated explainers, organised by subject.

Arrays and objects

An array is a numbered list, an object is a set of labelled values. An array of objects and a loop turn data into cards.

Try it

Transcript

An array is a numbered list of values. It lives in square brackets. The first item is number zero, and length tells you how many items there are.

An object is a set of labelled values, called properties. It lives in curly brackets. Use a dot and the property name to read one.

Put objects inside an array, and you have a collection: pets, games or books. Each object is one thing, and the array is the list of them.

A loop can go through the array and build one card for each object. Add one more object, and a new card appears, without changing the loop.

Remember: an array is a numbered list, an object is a set of labelled values, and a loop can turn an array of objects into cards.

More in this series