Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
0
81
Code Reuse in Node.js (the short version)
Makara Wang
April 20, 2013
Tweet
Share
More Decks by Makara Wang
See All by Makara Wang
Loose Coupling with Message Queue / Bus (the short version)
makara
1
93
Asynchronous JS with Promise (+ Workshop)
makara
0
84
Asynchronous JS with Promise
makara
2
150
Other Decks in Programming
See All in Programming
無秩序からの脱却 / Emergence from chaos
nrslib
2
13k
【CA.ai #3】ワークフローから見直すAIエージェント — 必要な場面と“選ばない”判断
satoaoaka
0
230
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
ttskch
3
790
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
420
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
120
複数人でのCLI/Infrastructure as Codeの暮らしを良くする
shmokmt
5
2.2k
MAP, Jigsaw, Code Golf 振り返り会 by 関東Kaggler会|Jigsaw 15th Solution
hasibirok0
0
230
バックエンドエンジニアによる Amebaブログ K8s 基盤への CronJobの導入・運用経験
sunabig
0
140
大体よく分かるscala.collection.immutable.HashMap ~ Compressed Hash-Array Mapped Prefix-tree (CHAMP) ~
matsu_chara
1
210
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
350
令和最新版Android Studioで化石デバイス向けアプリを作る
arkw
0
380
Go コードベースの構成と AI コンテキスト定義
andpad
0
120
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.4k
Testing 201, or: Great Expectations
jmmastey
46
7.8k
We Have a Design System, Now What?
morganepeng
54
7.9k
Code Reviewing Like a Champion
maltzj
527
40k
Typedesign – Prime Four
hannesfritz
42
2.9k
The Invisible Side of Design
smashingmag
302
51k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
A better future with KSS
kneath
240
18k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
54k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Into the Great Unknown - MozCon
thekraken
40
2.2k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
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!