# Object Literals & Properties — JavaScript

Source: https://www.geekswithgeeks.com/en/javascript/js-object-literals

> Creating objects and accessing their properties.

## Creating objects

Properties can be read with dot notation or bracket notation.

```js
const person = {
  name: "Ada",
  age: 36,
  isActive: true,
};
console.log(person.name);    // dot notation
console.log(person["age"]);  // bracket notation
```

## Adding & deleting

Assign to a new key to add a property; `delete` removes one entirely.

```js
person.city = "London";
delete person.isActive;
console.log(person);
```

## Dot vs bracket

Use bracket notation when the key is dynamic or not a valid identifier: `person["first-name"]`.
