JavaScript Tutorial

The language for programming web pages.

JS Objects

JavaScript Objects

In JavaScript, objects are king. Almost everything is an object. Objects are variables that can contain many values. Object values are written as name:value pairs (key:value).

Object Methods:

  • Object.keys(obj) — returns array of keys
  • Object.values(obj) — returns array of values
  • Object.entries(obj) — returns array of [key,value] pairs
  • Spread operator: { ...obj }
  • Destructuring: const { name } = obj

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics