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
0
80
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
92
Asynchronous JS with Promise (+ Workshop)
makara
0
82
Asynchronous JS with Promise
makara
2
150
Other Decks in Programming
See All in Programming
AI Coding Meetup #3 - 導入セッション / ai-coding-meetup-3
izumin5210
0
630
ててべんす独演会〜Flowの全てを語ります〜
tbsten
1
220
dynamic!
moro
9
6.8k
どの様にAIエージェントと 協業すべきだったのか?
takefumiyoshii
2
620
Reduxモダナイズ 〜コードのモダン化を通して、将来のライブラリ移行に備える〜
pvcresin
2
690
CSC305 Lecture 03
javiergs
PRO
0
240
Cloudflare AgentsとAI SDKでAIエージェントを作ってみた
briete
0
130
CSC305 Lecture 05
javiergs
PRO
0
210
WebエンジニアがSwiftをブラウザで動かすプレイグラウンドを作ってみた
ohmori_yusuke
0
170
CSC305 Lecture 02
javiergs
PRO
1
260
アメ車でサンノゼを走ってきたよ!
s_shimotori
0
200
Six and a half ridiculous things to do with Quarkus
hollycummins
0
120
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
27
2k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
A designer walks into a library…
pauljervisheath
209
24k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
19
1.2k
Faster Mobile Websites
deanohume
310
31k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
Balancing Empowerment & Direction
lara
4
680
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
4 Signs Your Business is Dying
shpigford
185
22k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.2k
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!