Syntax

JavaScript Create an Object Syntax

In JavaScript, create an object: creates key-value pairs — const user = { name: "Ada", age: 36 };

Quick Answer

Syntax
const user = { name: "Ada", age: 36 };
JavaScriptSyntax

Create an Object

Code example
const user = { name: "Ada", age: 36 };

Creates key-value pairs.

Learn More

How to create an object in JavaScript

  1. Open your JavaScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

JavaScript Create an Object Syntax

Use const user = { name: "Ada", age: 36 };.

Related Syntax References

Frequently asked questions

What is the JavaScript syntax for create an object?

Use this pattern: const user = { name: "Ada", age: 36 };

Can I copy this JavaScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this JavaScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify