JavaScript - Conditional & loop

iseon_u·2022년 4월 17일
0

JavaScript

목록 보기
2/5
post-thumbnail

Conditionals 조건문


if - else 문

if(condition){
	// condition === true exe
} else {
	// condition === false exe
}
  • 조건 결과 값은 boolean 타입

Loop 반복문


while 문

while (true) { console.log("Hi"); }

while (condition) { code ; }

  • 조건이 맞으면 틀릴 때까지 계속 반복 실행
  • 관습적으로 i 변수에 반복 횟수 변수 역할을 시킨다.

Boolean 논리 자료형


true - defined

const a = true;
// true
  • 1

false - defined

const a = false;
// false
  • 0
  • 거짓

null - defined

const a = null;
// null
  • “아무것도 없음” 이라는 값
  • 변수 안에 값이 없다는걸 명시

undefined

let a;
// undefined
  • 값이 정의 되지 않은 변수
  • 값이 없는 공간
profile
🧑🏻‍💻 Hello World!

0개의 댓글