DEV Community

Cover image for Arrays and Object Literals in JavaScript
Saqib Suleman
Saqib Suleman

Posted on

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

Oldest comments (0)