본문 바로가기

web116

ECMA6 # ECMA6 ##### [source : https://jsfiddle.net/softm/vcrfj2tu/ ](https://jsfiddle.net/softm/vcrfj2tu/) ※ 참고 : https://www.sitepoint.com/javascript-versioning-es6-es2015 # ECMAScript 2015 Releases - Classes - Promises - Arrow functions - ES Modules - Generators and Iterators # ES2016 - Array.prototype.includes // pre-ES2016: const hasBob = names.indexOf('bob') > -1; // ES2016: const hasBob = names... 2019. 7. 27.
date time random #### date time random ```javascript function randomTime(start, end) { var diff = end.getTime() - start.getTime(); var new_diff = diff * Math.random(); var date = new Date(start.getTime() + new_diff); return date; } document.write( randomTime(new Date(), new Date()) ); ``` 2019. 7. 26.
Node.js - Http Module #### #Node.js - Http Module #### # 참고 - [https://velopert.com/287](https://velopert.com/287) #### # index.html ```html <html> <head> <title>Sample Page</title> </head> <body> Hello World! </body> </html> ``` #### # server.js ```javascript var http = require('http'); var fs = require('fs'); var url = require('url'); // 서버 생성 http.createServer( function (request, response) { // URL 뒤에 있는 디렉토리/파일이름.. 2019. 7. 24.
Node.js - events Module & EventEmitter Class #### # Node.js - events Module & EventEmitter Class - EventEmitter는 Node.JS에 내장 옵저버 패턴의 구현 #### # 참고 - [https://www.haruair.com/blog/3396](https://www.haruair.com/blog/3396) - [nodejs.org : events](https://nodejs.org/dist/v5.5.0/docs/api/events.html) #### # event_emitter.js ```javascript var events = require('events'); var eventEmitter = new events.EventEmitter(); var connectHandler = function c.. 2019. 7. 23.
Node.js-Express ### # Node.js-Express ### # 참고 : https://velopert.com/379 ### # 디렉토리 구조 express_tutorial/ ├── data │ └── user.json ├── node_modules ├── package.json ├── public │ └── css │ └── style.css ├── router │ └── main.js ├── server.js └── views ├── body.ejs ├── header.ejs └── index.ejs ### # 의존 모듈 추가 ``` { "name": "express-tutorial", "version": "1.0.0", "dependencies": { "express": "~4.13.1", "ejs": "~2.4.. 2019. 7. 22.
Node.js #### # 참고 - [https://velopert.com/241](https://velopert.com/241) #### # [Node.js?](https://nodejs.org/ko/) - Chrome V8 JavaScript 엔진으로 빌드된 JavaScript Runtime. - 2009년에 Ryan Dahl에 의해 개발. - 이벤트 기반, 논 블로킹 I/O 모델. - Node.js의 패키지 생태계인 npm은 세계에서 가장 큰 오픈 소스 라이브러리. - 비동기 I/O 처리 . - 빠른 속도 - 단일 쓰레드 / 뛰어난 확장성 - 노 버퍼링 - 라이센스: MIT License #### # REPL (Read Eval Print Loop) - 읽고 값을 계산하고 출력하는 일을 반복하는 행위를 REPL .. 2019. 7. 21.