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
Code Reuse in Node.js (the short version)
Search
Makara Wang
April 20, 2013
Programming
91
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Code Reuse in Node.js (the short version)
Makara Wang
April 20, 2013
More Decks by Makara Wang
See All by Makara Wang
Loose Coupling with Message Queue / Bus (the short version)
makara
1
110
Asynchronous JS with Promise (+ Workshop)
makara
0
97
Asynchronous JS with Promise
makara
2
160
Other Decks in Programming
See All in Programming
FDEとは、何者なのか?
masapyon1212
0
110
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
550
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
270
AIの中の人になってみる
htkym
0
150
高専、大学編入、そして未踏へ〜プロダクト開発とキャリアの歩み - Technical College, University Transfer, and On to “Mitou” / My Journey in Product Development and Career
pkmiya
0
130
MySQLとPostgreSQLって何が違うの?
akagami
PRO
0
160
バグを直したら useEffect が消えた
colorful12
3
800
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.4k
週末にAI-DLCを本気で回したら$1,600溶けた
hbashimizu
0
120
Flow は今どうなっているか
mizdra
PRO
0
840
My Marp Sample
sinoue0108
0
140
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
180
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
How GitHub (no longer) Works
holman
316
150k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
From π to Pie charts
rasagy
0
350
Building Applications with DynamoDB
mza
96
7.2k
Rails Girls Zürich Keynote
gr2m
96
14k
Believing is Seeing
oripsolob
1
200
Deep Space Network (abreviated)
tonyrice
0
280
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
590
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
400
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.6k
Transcript
Code Reuse in Node.js (the short version) ⺩王浩宇 Makara Wang
[email protected]
2013.04.20
Assuming you know... JS & Node.js Prototype “this”
Common ways... Function + Arguments Good for: everything, promise, ...
Common ways... Prototype + Class Good for: modeling... ...or you
really care about performance ...or you want the long prototype chain
Common ways... Function Copy this[key] = that[key]; Good for: simpler
syntax, better syntax, ...
My favorite Function Copy ...with “Object.defineProperties()” Because it’s Node.js (not
a broken browser)
Implementations https://github.com/medikoo/es5-ext require('es5-ext/lib/Object/extend-properties'); https://github.com/devo-ps/carcass carcass.mixable(obj);
(Personal) Notes Use “this” Return “this” Reduce arguments Avoid “bind()”
...
Thanks!