Skip to content
dreamcode
dreamcode
Map
Objects
Lesson 16 of 48
+15 XP on finish
JAVASCRIPT CLIMBSChapter 3 · JS Collections & Loops

Labeled structures

JavaScript objects store key-value properties. You can declare them using curly braces {} and retrieve values using dot notation or bracket notation.

Worked example

How it reads

  • star.name uses dot notation to read the name property.
  • star["mag"] uses bracket notation to retrieve the magnitude.
Cloud tip: Objects are similar to Python dictionaries. Use keys (which must be valid strings) to store data.
index.js
JAVASCRIPT
real JavaScript, runs in your browser
Console
Run your code to see its output here.
YOUR TURN

Add a color property with the value "violet" and log the whole object: { shape: 'wispy', height: 3000, color: 'violet' }.

Press Run to check your work.