Arrays and Object Literals in JavaScript
Saqib Suleman
Posted on February 9, 2021
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];
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"]
}
💖 💪 🙅 🚩
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.