Javascript Tutorial #4.1 - Arrays

Sometimes, you might want to store more than one thing in a list of variables. Luckily, Javascript has an inbuilt feature for this, which is called an 'array'.

To make an array, you can use either var, let or const. The syntax goes as follows:
let <arrayName> = [1,2,3];
or
let <arrayName> = new [1,2,3];
of course replacing <arrayName> with the name you want your array to be and 'let' with either let, var, const. 1, 2 and 3 are the things that you want to be in your array, which can be the same things as can be stored in a let variable.

The objects in const arrays can be changed, but it cannot be changed to a variable or anything else.

CHALLENGE: Make an array with 5 different animals and then console.log the array.

If you have any questions, let me know on the comments.
- Noah

Comments