What is a JSON?
Part of the Logic & Flow section of Coddy's JavaScript journey — lesson 15 of 65.
JSON (JavaScript Object Notation) is a way to store data in key-value pairs. Each entry has a key (often a string) and a value that can be a string, number, array, boolean, or even another JSON object. Think of it like a dictionary, where each word (key) has a definition (value).
To create a JSON you would write:
const obj = {
name: "Alex",
age: 30,
preferences: ["sports", "music"]
}To get the name we would write:
obj.name // Alex
obj["name"] // AlexTo update (or change) the value we would write:
obj.name = "John"
obj["name"] = "John"
// Both do the same
console.log(obj.name)
// JohnThis lesson includes a short quiz. Start the lesson to answer it and track your progress.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
Cheat sheet
JSON (JavaScript Object Notation) stores data in key-value pairs. Each key has a value that can be a string, number, array, boolean, or another JSON object.
Create a JSON object:
const obj = {
name: "Alex",
age: 30,
preferences: ["sports", "music"]
}Access values using dot notation or bracket notation:
obj.name // Alex
obj["name"] // AlexUpdate values:
obj.name = "John"
obj["name"] = "John"Try it yourself
This lesson doesn't include a code challenge.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Logic & Flow
1Strings In Depth
String FundamentalsIterate Over StringsTemplate LiteralsString MethodsRecap - String Weaver4JSON Part 2
Iterate Over JSONNested JSONJSON Optional ChainingShallow And Deep CopyRecap - Bicycle ShopRecap - Solar System10Manage Festival System
Project OverviewAdd Movies & Venues2Multi-dimensional Arrays
2D Arrays BasicsAccessing 2D Array ElementsNested Loops with 2D ArraysRecap - 2D ArraysMatrix Addition & SubstractionJagged Arrays3D Arrays And BeyondCommon 2D Array PatternsRecap - All About Arrays5Sets Part 1
What Is A Set?Iterating Over SetsAdding An ElementRemoving An ElementChecking If An Element ExistsSize And Is EmptyCopy And ClearRecap - Basic Of Sets8Arrays Interesting Topics
Array DestructuringSpread Syntax in ArraysSparse ArraysRecap - Arrays Workshop3JSON Part 1
What is a JSON?Check If Key ExistsObject MethodsThe Spread Operator Part 1The Spread Operator Part 2Remove KeysRecap - JSON Manipulate Keys