Arrays and Object Literals in JavaScript

saqibs3291

Saqib Suleman

Posted on February 9, 2021

Arrays and Object Literals in JavaScript

Arrays are like a set of primitive types that is used to store information in them in the form of numbers, strings, booleans etc. Arrays can be modified by adding or removing data.

let lottoNumbers = [1, 2, 3, 4, 5, 6];
Enter fullscreen mode Exit fullscreen mode

Object literals are also like arrays except for the fact that data is stored in them with a key. Every primitive type data that is stored in them has a key assigned to it which can then be called out to display or modify that data.

let product = {
    name: "Gummy Bears",
    inStock: true,
    price: 1.99,
    flavors: ["grape","apple","cherry"]
}
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
saqibs3291
Saqib Suleman

Posted on February 9, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related