Arrays & Objects

Tools to use

Arrays & Objects 

These are some data structures that are used to store data in javaScript.

 

Data stored can be;

- Scores of players in a game

- List of todo's 

- Collection of Movies

- A list of favourite animations

-  Deatils of an person

Arrays 

An Array is used to store an ordered collection of data.

It is a better and convenient way of storing data of the same type.

 

Arrays can be called a  list;

- List of players in a team

- List of students in a class

- List of favorite Movies

- Bucket list

Let's use Arrays 

  • Arrays can be created using square brackets - [ ] 
  • Can be assigned to variables
  • Values added are separated by commas
  • Values are accessed using indexes

 

Arrays can be manipulated using these methods;

- array.pop() 

- array.push()

- array.shift()

- array.unshift()

Objects

Objects are a collection of unordered but related properties. Usually with Key and value pairs for each property.
 

Objects can be;

- Used to store details of a person 

- Store details of a car

Let's use Objects

  • Objects are created using a pair of curly brackets { }
  • Data is added as a key-value pair
     

Operations on Objects;

- Accessing values using the dot notation 

- Adding new properties

- Deleting properties

Practise On FreeCodeCamp

Go to freecodecamp and work on the code challenges on Arrays and Objects to understand how to use them well.

💡💡

** The End **

Arrays and Objects

By Roland Sankara

Arrays and Objects

  • 2