# 변수와 상수, 대입 연산자

## 📕 변수(Variable) 와 상수(Constant)

* 변수는 변하는 값이고 상수는 변하지 않는 값 즉, 변수는 값을 할당하여 사용하는 박스의 역할을 수행하고, 상수는 값 자체(1, 2 등)를 의미함
* 변수 할당은 var키워드를 이용해서 선언하고 대입 연산자(=)를 이용해 값을 할당함 (var 변수명 = 대입할 값)

```markup
<h1>변수와 상수</h1>
<script>
    // a는 변수 123은 상수, 대입연산자 : =
    var a = 123; // 변수 a에 123을 대입
    document.write(a);
</script>
```

{% embed url="<https://codepen.io/hyeongkyupark/pen/MWpGmKw>" %}

* 변수 명명 규칙
  * 변수명에는 오직 문자와 숫자, 그리고 기호 `$`와 `_`만 들어갈 수 있음
  * 첫 글자는 숫자가 될 수 없


---

# 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://phg0644.gitbook.io/javascript/undefined-2.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.
