# 2.1.4 Object Literals

假如 **JSON** 內的元素其 **key** 與 **value** 名稱一樣，可以省略 **key** 直接寫 **value** 名稱即可。

```
// ES5寫法
var name = 'Andy';
var obj = {
  name: name
};

// ES6寫法
const name = 'Andy';
const obj = { name };
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jack1in.gitbook.io/font-end/2.-javascript/2.1-es6/2.1.4-object-literals.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
