So far, you have learned about basic data types, including;
You have also learned how to store a single piece of data with a binding or variable. However, there are many instances where it is necessary for you to reference and manage multiple pieces of data from a single binding. This could be for simplicity in your code, or because a collection of data is related and should be kept together.
In computer science, a data structure is a particular way of organizing data in a computer so that it can be used efficiently. From Wikipedia
There are many different types of data structures. If you plan to work extensively with code after school (i.e. a developer job), you should take care to learn some of these. There are many resources for learning these, as a preview, you can check out;
For this week, you are going to learn three simple, and highly common data structures that are used in JS.
An array is a data structure that contains a group of elements. Typically these elements are all of the same data type, such as an Number or string. Arrays are commonly used in computer programs to organize data so that a related set of values can be easily sorted or searched. From Tech Terms
An array is a collection of data in “indexed” locations.
In JavaScript, objects can be seen as a collection of properties. With the object literal syntax, a limited set of properties are initialized; then properties can be added and removed. Property values can be values of any type, including other objects, which enables building complex data structures. Properties are identified using key values. A key value is either a String or a Symbol value.
In JS, the object data structure can be used to create sets of different types of data. Each piece of data is stored within the object using a unique key value (aka. identifier).
JSON (JavaScript Object Notation) is a multi-language format for sharing collections of data. However, it is based on the JS Object, therefore, you will not have to really learn too much new. Instead, you need to make sure you learn about JS Objects, how to create them, manipulate them, and read them.
To get started, please read the following, which cover the usage and definition of functions in great detail;
While you work on this chapter, you should use the following interactive JS console to test.