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
89
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
100
Asynchronous JS with Promise (+ Workshop)
makara
0
96
Asynchronous JS with Promise
makara
2
160
Other Decks in Programming
See All in Programming
アルゴリズムは何を圧縮しているのか ─ Haskell から育った「圧縮代数」というメンタルモデル
naoya
16
3.5k
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
130
どこまでゆるくて許されるのか
tk3fftk
0
510
SREは、MCPとSRE Agentをこう使え!
kazumax55
0
150
えっ!!コードを読まずに開発を!?
hananouchi
0
220
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
120
20260623_Loop Engineeringで自分の分身の問い合わせBotを作る
ryugen04
0
230
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
510
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
530
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
140
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
8
4.7k
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.9k
Featured
See All Featured
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
400
Producing Creativity
orderedlist
PRO
348
40k
Designing Powerful Visuals for Engaging Learning
tmiket
1
450
Visualization
eitanlees
152
17k
Accessibility Awareness
sabderemane
1
160
Done Done
chrislema
186
16k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
Designing for humans not robots
tammielis
254
26k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1k
The Cult of Friendly URLs
andyhume
79
7k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
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!