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
gfnork
June 20, 2014
Programming
0
430
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
450
gfnork node.js workshop Lesson #1 JavaScript Basics
freundschaft
0
860
gfnork node.js workshop Lesson #2 JavaScript Async
freundschaft
0
850
gfnork node.js workshop Lesson #4 middleware for node
freundschaft
0
460
gfnork node.js workshop Lesson #5 node.js databases
freundschaft
0
430
gfnork node.js workshop Lesson #6 Unit testing
freundschaft
0
420
Other Decks in Programming
See All in Programming
AmperとFleetを使ったAndroidアプリ
yoppie
0
300
RaaP
ksss
0
160
戦略的DDDは重いのか? / Is strategic DDD heavy?
pictiny
3
2.1k
CREってこういうこと? 体験入社 - 提案資料 - / what-is-cre-trial-employment
shinden
1
620
otelcol receiver 自作RTA / Pepabo Tech Conference #22 春のSREまつり
arthur1
0
970
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
1
130
Slackワークフローで感謝を伝える機能/WiFi 自動接続/Figma to React Component/障害レポート君 Team3@NOT A HOTEL
nakaohiroshi
0
110
slog登場に伴うloggerの取り回し手法の見直し / kamakura.go #6
arthur1
0
140
Enjoy Creative Coding with Ruby (RubyKaigi2024)
chobishiba
0
660
Revisiting the Hotwire Landscape after Turbo 8 @ RailsConf 2024, Detroit
marcoroth
3
610
Next.js App Router
quramy
14
2.3k
RustでAWS Lambda functionをいい感じに書く
taiki45
2
150
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
12
1.1k
Making the Leap to Tech Lead
cromwellryan
125
8.6k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
275
13k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
221
21k
Art, The Web, and Tiny UX
lynnandtonic
290
19k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
15
1.6k
Stop Working from a Prison Cell
hatefulcrawdad
266
19k
A Philosophy of Restraint
colly
197
16k
WebSockets: Embracing the real-time Web
robhawkes
59
7k
What's in a price? How to price your products and services
michaelherold
238
11k
Building Flexible Design Systems
yeseniaperezcruz
320
37k
The Power of CSS Pseudo Elements
geoffreycrofte
62
5k
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