논리연산자
-
[TIL] Today I Learned : 수학표현식, 논리연산자, 가위 바위 보 게임 함수 만들기(rockPaperScissors 함수)프론트엔드 개발자가 될거야./js 2022. 6. 23. 15:25
공부하다가 헷갈리는 개념들이 있어서 정리해보려고 한다. 간단하지만 헷갈리는...... 컴퓨터 언어에서 사용되는 수학 표현식 let num = 1; num++; console.log(num); // 2 num++는 풀어서 쓰면 num = num + 1; 이다. let num = 1; let newNum = num++; console.log(num); // 2 console.log(newNum); // 1 잠시 여기서 의문! num도 2고 newNum도 2 일 줄 알았는데..... 왜 저런 답이 나왔을까? let newNum = num++;을 풀어서 써보면 let newNum = num = num + 1 이다. newNum = num ---> newNum = 1 이고 그 다음에 num + 1 을 해주어서 n..