all is well!!

3. 증감 연산자 본문

Javascript 공부

3. 증감 연산자

tnqlscho 95 2023. 2. 20. 20:50

증가 연산자

++ (1증가)

++num , num++

++num : 선증가 후연산

num++ : 선연산 후증가

 

감소 연산자

-- (1감소)

--num , num--

--num : 선감소 후연산

num-- : 선연산 후감소

var num1=10

var num2=10

console.log(num1,"<br>")//10

console.log(num1++,"<br>")//10

console.log(num1,"<br>")//11

console.log("<br>")

console.log(num2,"<br>")//10

console.log(num2,"<br>")//11

 

---

 

num=num+1

대입 연산자는 오른쪽부터 왼쪽 흐름

오른쪽의 값이 왼쪽의 공간에 들어간다.

num값에 1을 더한 값을 num변수(공간)에 넣는다.

오른쪽은 값이고, 왼쪽은 공간이다.

'Javascript 공부' 카테고리의 다른 글

6. 프로그래밍  (0) 2023.05.10
5. 클로저  (0) 2023.05.09
4. 스코프 체이닝  (0) 2023.05.05
2. 논리 연산자  (0) 2023.01.24
1. [js] 배열을 변경할때 리렌더링 일어나지 않음  (0) 2023.01.23
Comments