Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
gfnork node.js workshop Lesson #3 node.js basics
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
gfnork
June 20, 2014
Programming
0
470
gfnork node.js workshop Lesson #3 node.js basics
first steps, modules, npm, Events
gfnork
June 20, 2014
Tweet
Share
More Decks by gfnork
See All by gfnork
Basic Mobile Application Design
freundschaft
0
510
gfnork node.js workshop Lesson #1 JavaScript Basics
freundschaft
0
960
gfnork node.js workshop Lesson #2 JavaScript Async
freundschaft
0
960
gfnork node.js workshop Lesson #4 middleware for node
freundschaft
0
520
gfnork node.js workshop Lesson #5 node.js databases
freundschaft
0
470
gfnork node.js workshop Lesson #6 Unit testing
freundschaft
0
460
Other Decks in Programming
See All in Programming
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
270
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
610
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
3.9k
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
140
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.6k
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
Oxlintはいいぞ
yug1224
5
1.3k
CSC307 Lecture 07
javiergs
PRO
1
550
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
220
組織で育むオブザーバビリティ
ryota_hnk
0
180
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
7.4k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
590
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
Believing is Seeing
oripsolob
1
56
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
37k
How to Ace a Technical Interview
jacobian
281
24k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
180
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
WCS-LA-2024
lcolladotor
0
450
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
97
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.7k
Automating Front-end Workflow
addyosmani
1371
200k
Done Done
chrislema
186
16k
Transcript
None
2
3
4
5
6
7
8 node > console.log('Hello World'); Hello World
9 console.log('Hello World'); >node app.js Hello World
10 var http = require('http'); http.createServer(function (req, res) { res.writeHead(200,
{ 'Content-Type': 'text/plain' }); res.end('Hello World\n'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/');
11 var http = require('http'); http.createServer(function (req, res) { res.writeHead(200,
{ 'Content-Type': 'text/plain' }); res.end('Hello World\n'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/');
12
13 exports.helloworld = function () { console.log('Hello World'); } var
test = require('./test.js'); test.helloworld();
14 module.exports = function () { this.name = "test object";
this.color = "red"; this.size = "large"; } var test = require('./test.js'); var testObject = new test(); console.log('name:' + testObject.name); console.log('color:' + testObject.color); console.log('size:' + testObject.size);
15
16
17 { "name": "TestNodejsApp", "version": "0.0.0", "description": "TestNodejsApp", "private": true,
"main": "app.js", "author": { "name": "Qiong Wu", "email": "" }, "dependencies": { "express": "3.4.4", "jade": "*", "stylus": "*" } }
18
19
20 server.on('connection', function (stream) { console.log('someone connected!'); }); server.once('connection', function
(stream) { console.log('Ah, we have our first user!'); });
21 function Test(colour) { this.colour = colour; events.EventEmitter.call(this); this.sendEvent =
function() { this.emit('EventSent'); } } Test.prototype.__proto__ = events.EventEmitter.prototype; var testObject = new Test('white'); testObject.on('EventSent', function() { console.log('Event received'); }); testObject.sendEvent();
22
23 // write 'hello, ' and then end with 'world!'
http.createServer(function (req, res) { res.write('hello, '); res.end('world!'); // writing more now is not allowed! });
24