← CodePrimer
JavaScript Beginner Basics

JavaScript object basics

How do I store keyed data in JS?

Object literals.

Sample
const student = { name: 'Ada', year: 1 };
console.log(student.name);
student.year = 2;

Notes

JSON is the text format; objects are the in-memory structure.

Keywords: object · key · value · literal

Related

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share