What are ARRAYS in programming?
Arrays in programming are essentially ways of storing lists of things in a program or app.
The way to store these lists, will depend on the programming language you use.
So, suppose you need to make a list of things to buy.
What you would usually do is take out a piece of paper from a notebook and write everything you need to buy.
You decide there's a better way. Make a program on your computer instead!
So how would you store this list?
We've talked about variables before. Basically a way to store things that would be used later.
Same way we store text or numbers, we can store lists of text or numbers.
In our case, we want to store a list of items to buy. That means we need a text list!
let stuffToBuy = ["Milk", "Orange juice", "A laptop for coding"]
In Python, it's similar:
stuffToBuy = ["Milk", "Orange juice", "A laptop for coding"]
Now you can do stuff like, select a specific item in the list, depending on its position:
stuffToBuy // ==> Orange juice
Add (push) stuff to your list:
Check how large a list is:
let stuffToBuy = ["Milk", "Orange juice", "A laptop for coding"] stuffToBuy.length // 3
Or go through each and every element in the list and so something specific with it.
This is called a "loop" and it's something we'll talk about in another thread, so watch this space.
Thank you for reading!
Explained (28 part series)
- Accessibility, explained.
- React, explained
- Should I use forEach() or map()?
- Should I use Flexbox or CSS Grid?
- Docker, explained.
- Unit testing, explained
- Git, explained.
- Typescript, explained.
- async/await, explained.
- The DOM, explained.
- Regular expressions, explained
- GraphQL, explained.
- Vue, explained.
- Svelte, explained.
- API, explained.
- Immediately Invoked Function Expressions (IIFE), explained.
- ARIA roles, explained.
- Test-driven Development, explained.
- ARIA live regions, explained.
- aria-label in accessibility, explained.
- Variables, explained.
- if statements, explained.
- Arrays, explained.