수

nodejs 기초문법 - 조건문 반복문

· 2019-01-12 (토) 23:08:42 · 3051

기초문법

 

다. 조건문

javascript 에는 조건문으로 if 와 switch 가 있는데 이 강좌에서는 if 만 사용하도록 하겠습니다.
조건문의 구조는 타 언어와 유사합니다.
var a = 10;

if (a > 11) {
    console.log('a가 11보다 큽니다'); 
} else if(a == 11) {
    console.log('a가 11과 같습니다');
} else {
    console.log('a가 11보다 작습니다');
}
* console은 node.js 에서 콘솔화면에 로그를 사용하기 위한 내장객체이고, 멤버변수인 log('내용')로 로그를 출력할 수 있습니다.

 

라. 반복문

반복문에는 for 와 while, do ~ while 이 있습니다. 이 강좌에서는 while 문만 사용하겠습니다.
// 0부터 9까지 출력하는 while문
var i=0;
while(i < 10) {
    console.log("for : i의 값은="+i);
    i=i+1;
}

|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
PHP 19-06-24 조회 3,212
PHP 19-06-09 조회 3,833
MySQL 19-04-01 조회 4,891
jQuery 19-03-20 조회 4,275
node.js 19-02-12 조회 3,376
node.js 19-02-12 조회 3,115
node.js 19-02-12 조회 3,376
node.js 19-02-07 조회 3,347
node.js 19-02-07 조회 3,091
node.js 19-02-07 조회 3,228
node.js 19-02-04 조회 2,974
node.js 19-02-04 조회 2,949
node.js 19-02-04 조회 3,390
node.js 19-01-31 조회 2,498
node.js 19-01-31 조회 2,653
node.js 19-01-31 조회 3,125
node.js 19-01-28 조회 2,913
node.js 19-01-28 조회 2,980
node.js 19-01-28 조회 2,818
node.js 19-01-22 조회 3,168
node.js 19-01-22 조회 2,907
node.js 19-01-22 조회 3,361
node.js 19-01-16 조회 2,784
node.js
[node.js]
19-01-16 조회 2,673
node.js 19-01-16 조회 9,353
node.js 19-01-12 조회 4,427
node.js 19-01-12 조회 3,052
node.js 19-01-12 조회 3,172
node.js 19-01-11 조회 2,719
node.js 19-01-11 조회 4,077