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
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
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
460
組織で育むオブザーバビリティ
ryota_hnk
0
180
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
590
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
5
740
要求定義・仕様記述・設計・検証の手引き - 理論から学ぶ明確で統一された成果物定義
orgachem
PRO
1
150
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
300
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
3.9k
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
140
Claude Codeと2つの巻き戻し戦略 / Two Rewind Strategies with Claude Code
fruitriin
0
130
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
Basic Architectures
denyspoltorak
0
680
CSC307 Lecture 04
javiergs
PRO
0
660
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
432
66k
Skip the Path - Find Your Career Trail
mkilby
0
57
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Evolving SEO for Evolving Search Engines
ryanjones
0
130
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
69
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
190
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
3.9k
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