# 객체

## 객체

#### 데이터를 담아내는 컨테이너.  **여러 속성을 하나의 변수에 저장할 수 있도록 해주는 데이터 타입**으로 Key / Value Pair를 저장할 수 있는 구조이다.

### 객체의 생성&#x20;

```javascript
var grades = {'egoing': 10, 'k8805': 6, 'sorialgi': 80};
```

```javascript
var grades = {};
grades['egoing'] = 10;
grades['k8805'] = 6;
grades['sorialgi'] = 80;
```

```javascript
var grades = new Object();
grades['egoing'] = 10;
grades['k8805'] = 6;
grades['sorialgi'] = 80;
```

변수에 객체의 값을 넣어준다.&#x20;

### 객체 불러오기

```javascript
var grades = {'egoing': 10, 'k8805': 6, 'sorialgi': 80};
alert(grades['sorialgi']); // 80
```

```javascript
alert(grades.sorialgi);//80
```

```javascript
var grades = {'egoing': 10, 'k8805': 6, 'sorialgi': 80};
for(let name in grades) {
    console.log(key); 
    console.(grades[key]);
    document.write("key : "+name+" value : "+grades[name]+"<br />");
}
//egoing
//k8805
//sorialgi
//10
//6
//80
// key : egoing value : 10 
// key k8805 value : 6
// key : sorialgi value : 80
```

```javascript
var grades = {'egoing': 10, 'k8805': 6, 'sorialgi': 80};
for(let name in grades) {
    document.write("<li>key : "+name+" value : "+grades[name]+"</li>");
}
// key : egoing value : 10 
// key k8805 value : 6
// key : sorialgi value : 80
```

html  \<ul>\<li> 만들어준후에 위의 자바스크립트를 입력 했을때 li에  해당 결과값이 화면에 나타난다.

```javascript
var grades = {
    'list': {'egoing': 10, 'k8805': 6, 'sorialgi': 80}, // 키안에 담겨있는 또다른 객
    'show' : function(){
        for(var name in this.list){
            document.write(name+':'+this.list[name]+"<br />");
        }
    }
};
grades.show();  
//egoing: 10 k8805: 6, sorialgi: 80
//this -> 약속되어있는 변수
// grades -> list , show  ( 객체지향 프로그래밍 )  
```


---

# 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://leeboa.gitbook.io/study/undefined-13/undefined-7.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.
