# 연산자

## 연산자(Operator)

> 연산자란 값에 대해서 어떤 작업을 컴퓨터에게 지시하기 위한 기호

## 1. 대입연산자(Assignment Operator)

> **'='** : 우항의 값을 좌항의 변수에 대입하는 연산자

```javascript
a = 1; //1을 a에 대입
```

## 2. 증감연산자(Increment & Decrement Operators)

```javascript
let a = 10;
let b = a++ + 5;
let c = b--;
// a = 11, b=14, c=15
```

```javascript
i++ // i를 먼저 출력 후 다음 값이 +1
++i // +1된 i의 값을 출력
```

## 3. 비교연산자(Comparison Operator)

* 주어진 값들이 같은지, 다른지, 큰지, 작은지를 구분 (=, <, >)
* **Boolean** : **true**나 **false**로 결과값을 출력

{% tabs %}
{% tab title="동등연산자 '=='" %}

* **'=='**
* 좌항과 우항을 비교해서 서로의 값이 같은지 다른지를 비교
  {% endtab %}

{% tab title="일치연산자 '==='" %}

* **'==='**
* 엄격한 동등연산자로, 좌항과 우항이 '정확'하게 같은지 다른지를 비교
  {% endtab %}
  {% endtabs %}

{% tabs %}
{% tab title="동등연산자" %}

```javascript
alert(1==2)             //false
alert(1==1)             //true
alert("one"=="two")     //false 
alert("one"=="one")     //true
```

{% endtab %}

{% tab title="일치연산자" %}

```javascript
alert(1=='1');          //true
alert(1==='1');         //false
```

{% endtab %}
{% endtabs %}

```javascript
//null과 undefined는 값이 없다는 의미의 데이터 형태
alert(null == undefined);       //true
alert(null === undefined);      //false
alert(true == 1);               //true
alert(true === 1);              //false
alert(true == '1');             //true
alert(true === '1');            //false

//NaN은 연산의 결과로 만들어지는 특수한 데이터 형태, 숫자가 아니라는 뜻 
alert(0 === -0);                //true
alert(NaN === NaN);             //false
```

### 3-1. 부등 !=, 불일치 !==

```javascript
alert(1!=2);            //true
alert(1!=1);            //false
alert("one"!="two");    //true
alert("one"!="one");    //false
```

### 3-2. 크기의 값 비교

```javascript
alert(10>20);  //false
alert(10>1);   //true
alert(10>10);  //false
alert(10>=20); //false
alert(10>=1);  //true
alert(10>=10); //true
```

## 4. 논리연산자

### 4-1. && (AND)

좌항과 우항이 모두 true일 때 true

```javascript
if(true && true){ //true
    alert(1); 
}
if(true && false){ //false
    alert(2);
}
if(false && true){ //false
    alert(3);
}
if(false && false){ //false
    alert(4);
}
```

### 4-2. || (OR)

하나라도 true라면 true

```javascript
if(true || true){ //true
    alert(1); 
}
if(true || false){ //true
    alert(2);
}
if(false || true){ //true
    alert(3);
}
if(false || false){ //false
    alert(4);
}
```

### 4-3. ! (NOT)

부정의 의미로, Boolean의 값을 true → false / false → true로 역전시키는 역할

```javascript
if(!true && !true){ //false
    alert(1);
}
if(!false && !true){ //false
    alert(2);
}
if(!true && !false){ //false
    alert(3);
}
if(!false && !false){ //true
    alert(4);
}
```


---

# 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://westsilver.gitbook.io/study-script/javascript/jacascript-start/undefined/untitled-5.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.
