# 데이터 타입

## 데이터 타입

### 원시 데이터 타입(기본 데이터 타입)

**객체가 아닌 데이터 타입**을 **원시 데이터 타입(primitive type)이라고 한다.** 그 외의 모든 데이터 타입들은 객체다.

* 숫자
* 문자열
* 불리언(true/false)
* null
* undefined

### 레퍼 객체

```javascript
var str = 'coding';
console.log(str.length);        // 6
console.log(str.charAt(0));     // "C"
```

문자열은 분명히 프로퍼티와 메소드가 있다. 그렇다면 객체다. **내부적으로 문자열이 원시 데이터 타입**이고 문자열과 관련된 어떤 작업을 하려고 할 때 자바스크립트는 **임시로 문자열 객체를 만들고 사용이 끝나면 제거**하기 때문이다. **이러한 처리는 내부적으로 일어난다.** 하지만 원시 데이터 타입과 객체는 좀 다른 동작 방법을 가지고 있기 때문에 이들을 분별하는 것은 결국엔 필요하다.

```javascript
var str = 'coding';
str.prop = 'everybody';
console.log(str.prop);      // undefined
```

**str.prop를 하는 순간**에 **자바스크립트 내부적으로 String 객체가 만들어진다. prop 프로퍼티**는 이 객체에 저장되고 **이 객체는 곧 제거** 된다. 그렇기 때문에 **prop라는 속성이 저장된 객체는 존재하지 않게된다.** 이러한 특징은 일반적인 객체의 동작 방법과는 다르다.

&#x20;**레퍼객체로는** [**String**](https://opentutorials.org/course/50/37)**,** [**Number**](https://opentutorials.org/course/50/40)**, Boolean이 있다. null과 undefined는 레퍼 객체가 존재하지 않는다.**


---

# 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-11/undefined-1.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.
