반응형

IT/javascript 24

조건문 - if, else, else if, switch case

if const a = 1; if ( a + 1 === 2 ) { console.log('a+1은 2입니다.'); } -----------------------출력 : a+1은 2입니다. const a = 1; if ( a = 1 ===2 ) { const a = 2; console.log('if문 안의 a 값은' + a); ----------출력 : if문 안의 a 값은 2 } console.log('if문 밖의 a 값은' + a); ----------출력 : if문 밖의 a 값은 1 => {}중괄호를 하나의 블록 범위로 본다. 다른 블록 안에서 같은 상수(const) 또는 변수(let)를 사용할 수 있다. if else const a = 10; if ( a > 15 ) { console.log('a가..

IT/javascript 2020.07.13

자바스크립트 논리연산자 (! && ||)

논리연산자에는 not, and, or 이라는 세가지 종류가 있다. 계산 우선순위는 다음과 같다. NOT(!) -- AND(&&) -- OR(||) NOT은 true를 false로, false를 true로 변경해준다. const a = !true; console.log(a); --------- 결과값은 false const b = !false; console.log(b); --------- 결과값은 true AND는 양쪽의 값이 모두 true 일때만 결과값이 true const a = true && true; console.log(a); --------- 결과값은 true const b = false && true; console.log(b); --------- 결과값은 false const c = fal..

IT/javascript 2020.07.11

javascript 사칙연산자

let a = 1; console.log(a++); ----------- 1이 더해지기 전. a는 1. 결과값은 1 console.log(a); ------------- 위의 1이 더해진 상태. 결과값은 2 console.log(++a); ------------- 1이 더해진 후. 결과값은 3 let a =1; console.log(a--); ------------ 1을 빼기 전. 결과값은 1 console.log(a); -------------- 위의 1이 빼진 상태. 결과값은 0 console.log(--a); -------------- 1을 뺀 후. 결과값은 -1 let a = 1; a += 1; ------------- a+1과 같은 의미 console.log(a); -------------- 결..

IT/javascript 2020.07.11
반응형