수

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

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

기초문법

 

다. 조건문

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,189
PHP 19-06-09 조회 3,811
MySQL 19-04-01 조회 4,864
jQuery 19-03-20 조회 4,248
node.js 19-02-12 조회 3,351
node.js 19-02-12 조회 3,085
node.js 19-02-12 조회 3,348
node.js 19-02-07 조회 3,325
node.js 19-02-07 조회 3,064
node.js 19-02-07 조회 3,210
node.js 19-02-04 조회 2,947
node.js 19-02-04 조회 2,921
node.js 19-02-04 조회 3,369
node.js 19-01-31 조회 2,478
node.js 19-01-31 조회 2,628
node.js 19-01-31 조회 3,106
node.js 19-01-28 조회 2,868
node.js 19-01-28 조회 2,951
node.js 19-01-28 조회 2,792
node.js 19-01-22 조회 3,121
node.js 19-01-22 조회 2,886
node.js 19-01-22 조회 3,309
node.js 19-01-16 조회 2,754
node.js
[node.js]
19-01-16 조회 2,649
node.js 19-01-16 조회 9,325
node.js 19-01-12 조회 4,403
node.js 19-01-12 조회 3,003
node.js 19-01-12 조회 3,152
node.js 19-01-11 조회 2,696
node.js 19-01-11 조회 4,051