Skip to content

Making Lists: Arrays

An Array is an ordered list of items. You create an array using square brackets [], with each item in the list separated by a comma. This is similar to how arrays are defined in JSON and other common data formats. See how MON compares.

Arrays are perfect for collections of things, like a list of tags, a group of users, or a sequence of steps.

You can create a simple list of primitive values like strings or numbers.

{
// A list of strings
tags: ["tutorial", "mon", "beginner"],
// A list of numbers
winning_numbers: [12, 45, 77, 81],
}

More powerfully, you can create a list where each item is an object. This is a fundamental pattern for structuring complex data.

{
// A list of users, where each user is an object
users: [
{
name: "Alice",
role: "admin",
},
{
name: "Bob",
role: "viewer",
},
],
}

Excellent! You can now structure both single items and lists of items. Next, we’ll learn how to stop repeating ourselves by reusing data within a file.