Notice
                              
                          
                        
                          
                          
                            Recent Posts
                            
                        
                          
                          
                            Recent Comments
                            
                        
                          
                          
                            Link
                            
                        
                    | 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | 
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | 
| 30 | 
                            Tags
                            
                        
                          
                          - cmd mariaDB
- SQL
- 알고리즘
- 포워드 엔지니어링
- 자바 로또
- nodejs http
- map형태 jsp와 mapper
- 유효성
- $(document).on
- 최대값 최소값
- templet
- bubblesort
- ${}
- 자바 예상문제
- container-fluid
- nodejs
- MariaDB
- git 명령어
- $('input [name=
- git
- #{}
- BCrypt
- interface default
- gradle 설치
- git message
- resultType="hashmap"
- it지원
- a href="#" onclick="return false"
- REST
- 전역객체
                            Archives
                            
                        
                          
                          - Today
- Total
Rubberduck-Debugging
node js 전역객체 실습 본문
1. 기본 모듈 
-프로세스 환경
  os, process
-파일과 경로 , URL
 fs, path, URL, querystring, stream
-네트워크 모듈
 http, net, dns 
2. 전역객체(global)
  (Java 에서 Console 클래스 사용하는 것처럼 ....)
 -별도의 모듈 로딩 없이 사용가능
 -global.console.log()  >>  console.log()   >> global 생략가능
3. 전역객체 
 -process
 -console
 -Buffer
 -require
 -__filename, __dirname
 -module
 -exports
 -Timeout 함수 등
4. 실습
*process.js
console.log(process.env);
console.log(process.arch);
console.log(process.platform);
*timeout.js
function sayHello() {
 console.log('Hello World');
}
setTimeout(function() {
 sayHello();
}, 2*1000);
*Interval.js
function sayGoodbye(who) {
   console.log('Good bye', who);   
}
*console.js
var intVal = 3;
var obj = {
 name : 'NodeJS',
 how : 'Interesting'
};
console.log('hello world');
console.log('intVal : ' + intVal);
console.log('obj : ' + obj);
console.log('obj : ', obj);
setInterval(sayGoodbye, 1 * 1000, 'Friend');
*console_custom.js
var fs = require('fs');
var output = fs.createWriteStream('stdout.log');
var errorOutput = fs.createWriteStream('error.log');
var Console = require('console').Console;
var logger = new Console(output, errorOutput);
logger.info('info message');
logger.log('log message');
logger.warn('warning');
logger.error('error message');
*consoleTime.js
console.time('TIMER');
var sum = 0;
for(var i = 1 ; i < 100000; i++ ) {
 sum += i;
}
console.log('sum : ', sum);
console.timeEnd('TIMER');
*util.js
var util = require('util');
var str1 = util.format('%d + %d + %d', 1, 2, (1+2));
console.log(str1);
var str2 = util.format('%s %s', 'Hello', ' NodeJS');
console.log(str2);
*util_inherit.js
var util = require('util');
function Parent() {
}
Parent.prototype.sayHello = function() {
 console.log('Hello World, from Parent Class!');
}
var obj = new Parent();
obj.sayHello();
function Child() {
}
// 상속
util.inherits(Child, Parent);
var obj2 = new Child();
obj2.sayHello();
5. Node.js 애플리케이션의 이벤트들
 --클라이언트의 접속 요청
 --소켓에 데이터 도착
 --파일 오픈/읽기 완료
 -이벤트 처리
 --비동기 처리
 --리스너 함수
process.on('exit', function() {console.log('occur exit event');}); 
process.once('exit', function() {console.log('occur exit event');});
process.emit('exit');  //이벤트 발생
'개발자 > 20181127 교육과정' 카테고리의 다른 글
| nodeJS npm (0) | 2019.01.07 | 
|---|---|
| nodeJS 비동기식, 파일 다루기 (0) | 2019.01.07 | 
| node js 강의 (0) | 2019.01.04 | 
| jquery radio,checkbox value값 가져오기 $("input:checkbox (0) | 2019.01.02 | 
| ajax json 응답 @ResponseBody 정리 (0) | 2019.01.01 | 
