-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
index.html
319 lines (284 loc) · 29.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!-- Consider adding a manifest.appcache: h5bp.com/d/Offline -->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<!-- Use the .htaccess and remove these lines to avoid edge case issues.
More info: h5bp.com/b/378 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>JavaScript Patterns</title>
<meta name="description" content="JavaScript patterns and antipatterns collection">
<meta name="author" content="Shi Chuan">
<!-- Mobile viewport optimized: h5bp.com/viewport -->
<meta name="viewport" content="width=device-width,initial-scale=1">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory: mathiasbynens.be/notes/touch-icons -->
<link href='http://fonts.googleapis.com/css?family=Tinos:400,700,400italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/style.css">
<!-- More ideas for your <head> here: h5bp.com/d/head-Tips -->
<!-- All JavaScript at the bottom, except this Modernizr build incl. Respond.js
Respond is a polyfill for min/max-width media queries. Modernizr enables HTML5 elements & feature detects;
for optimal performance, create your own custom Modernizr build: www.modernizr.com/download/ -->
<script src="js/libs/modernizr-2.0.6.min.js"></script>
</head>
<body>
<a class="fork" href="https://github.com/shichuan/javascript-patterns">
<img src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub">
</a>
<header>
<div class="clearfix">
<h1>JavaScript Patterns Collection</h1>
<div id="btns">
<span class='st_sharethis_hcount' displayText='ShareThis'></span><span class='st_twitter_hcount' displayText='Tweet'></span><span class='st_facebook_hcount' displayText='Facebook'></span><span class='st_plusone_hcount' ></span>
</div>
</div>
<img src="img/js-patterns.png" alt="JS Patterns" title="JS Patterns" />
<nav id="toc" class="sticky">
<ul>
<li><a href="#general-patterns">General Patterns</a></li>
<li><a href="#jquery-patterns">jQuery Patterns</a></li>
<li><a href="#jquery-plugin-patterns">jQuery Plugin Patterns</a></li>
<li><a href="#literals-and-constructor">Literals and Constructor Patterns</a></li>
<li><a href="#function-patterns">Function Patterns</a></li>
<li><a href="#object-creation-patterns">Object Creation Patterns</a></li>
<li><a href="#code-reuse-patterns">Code Reuse Patterns</a></li>
<li><a href="#design-patterns">Design Patterns</a></li>
</ul>
</nav>
</header>
<div role="main">
<section id="intro">
<p>A JavaScript pattern and antipattern collection that covers function patterns, jQuery patterns, jQuery plugin patterns, design patterns, general patterns, literals and constructor patterns, object creation patterns, code reuse patterns, DOM and browser patterns (<em>upcoming</em>).</p>
Patterns collected while developing <a href="http://www.xigan.com">喜感网</a>.</p>
</section>
<section id="general-patterns">
<h2>General Patterns</h2>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/function-declarations.html" target="_blank">Function Declarations</a> - creating anonymous functions and assigning them to a variable</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/conditionals.html" target="_blank">Conditionals</a> - pattern and antipattern of using if else</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/access-to-global-object.html" target="_blank">Access to the Global Object</a> - access the global object without hard-coding the identifier window</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/single-var-pattern.html" target="_blank">Single var Pattern</a> - use one var statement and declare multiple variables</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/hoisting.html" target="_blank">Hoisting</a> - var statements anywhere in a function act as if the variables were declared at the top of the function</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/for-loops.html" target="_blank">for loops</a> - optimized for loops</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/for-in-loops.html" target="_blank">for-in loops</a> - optimized for-in loops</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/built-in-prototypes.html" target="_blank">(Not) Augmenting Built-in Prototypes</a> - only augment built-in prototypes when certain conditions are met</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/switch-pattern.html" target="_blank">switch Pattern</a> - improve the readability and robustness of your switch statements</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/avoiding-implied-typecasting.html" target="_blank">Implied Typecasting</a> - avoid implied typecasting</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/avoiding-eval.html" target="_blank">Avoiding eval()</a> - avoid using eval()</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/parseint.html" target="_blank">Number Conversions with parseInt()</a> - use the second radix parameter</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/minimizing-globals.html" target="_blank">Minimizing Globals</a> - create and access a global variable in a browser environment</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/globals.html" target="_blank">The Problem with Globals</a> - various problems with globals</li>
</ul>
</section>
<section id="jquery-patterns">
<h2>jQuery Patterns</h2>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/requery.html" target="_blank">requery</a> - avoid requery by using jQuery chaining</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/append.html" target="_blank">append</a> - use string concatenate and set innerHTML</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/data.html" target="_blank">data</a> - pattern and antipattern of using data</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/context-and-find.html" target="_blank">context and find</a> - use find over context</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/detach.html" target="_blank">detach</a> - take element off the DOM while manipulating them</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/event-delegation.html" target="_blank">event delegation</a> - event delegation pattern and antipattern</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/cache-selector.html" target="_blank">selector cache</a> - using selector cache to avoid requery</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/window-scroll-event.html" target="_blank">window scroll event</a> - avoid attaching handlers to the window scroll event</li>
</ul>
<h3>Selector</h3>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/left-and-right.html" target="_blank">Left and Right</a> - specific on the right, light on the left</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/decending-from-id.html" target="_blank">Decending from id</a> - be more specific</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/universal-selector.html" target="_blank">Universal Selector</a> - use of universal selector</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/specific-when-needed.html" target="_blank">Be Specific when Needed</a> - be specific only when needed</li>
</ul>
<h3 id="jquery-pubsub">Publish–subscribe</h3>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/pubsub-custom-events.html" target="_blank">Method 1</a> - custom events using .on() and .off()</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/pubsub-callback.html" target="_blank">Method 2</a> - using jQuery 1.7's $.Callbacks() feature</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/pubsub-observable.html" target="_blank">Method 3</a> - using jQuery UI $.Observable</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/pubsub-plugin.html" target="_blank">Method 4</a> - third-party plugins</li>
</ul>
</section>
<section id="jquery-plugin-patterns">
<h2>jQuery Plugin Patterns</h2>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/basic.html" target="_blank">Basic</a> - the most basic pattern</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/extend.html" target="_blank">Extend</a> - enables you to define multiple functions at once and which sometimes make more sense semantically</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/lightweight.html" target="_blank">Lightweight</a> - perfect as a generic template for beginners and above</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/namespaced-starter.html" target="_blank">Namespaced pattern</a> - to avoid collisions and improve code organization when working with components under another namespace</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/prototypal-inheritance.html" target="_blank">Prototypal inheritance</a> - prototypal inheritance with the DOM-to-Object bridge pattern</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/best-options.html" target="_blank">Best options</a> - globally/Per-call overridable options for greater option customization</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/custom-events.html" target="_blank">Custom events (Pseudo Pub/Sub)</a> - for better application decoupling</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/highly-configurable-mutable.html" target="_blank">'Highly configurable' mutable</a> - define plugin’s logic using a constructor and an object literal defined on its prototype</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/ui-widget-factory.html" target="_blank">UI Widget factory</a> - for building complex, stateful plugins based on object-oriented principles</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/ui-widget-factory-bridge.html" target="_blank">UI Widget factory "bridge"</a> - the bridge serves as a middle layer between a JavaScript object that is created using $.widget and jQuery’s API</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/ui-widget-factory-mobile.html" target="_blank">UI Widget factory for jQuery mobile</a> - demonstrating best practices for building mobile widgets</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/ui-widget-requirejs-module.html" target="_blank">UI Widget + RequireJS module</a> - for wrapping jQueryUI widgets inside RequireJS compatible modules</li>
<li><a href="https://github.com/shichuan/javascript-patterns/tree/master/jquery-plugin-patterns/amd-commonjs" target="_blank">Universal Module Definition pattern</a> - create AMD and CommonJS compatible plugin modules which are compatible with a number of different script loaders</li>
</ul>
</section>
<section id="literals-and-constructor">
<h2>Literals and Constructors Patterns</h2>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/literals-and-constructors/object-literal.html" target="_blank">Object literal</a> - use the simpler and reliable object literal instead of new Object();</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/literals-and-constructors/enforcing-new.html" target="_blank">Enforcing new</a> - when you forget `new`, `this` inside the constructor will point to the global object</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/literals-and-constructors/array-literal.html" target="_blank">Array literal</a> - use array literal notation to avoid potential errors when creating dynamic arrays at runtime</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/literals-and-constructors/json.html" target="_blank">Working with JSON</a> - use library from JSON.org, YUI, jQuery instead of eval for parsing</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/literals-and-constructors/primitive-wrappers.html" target="_blank">Primitive wrappers</a> - try to use the primitive without wrapper</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/literals-and-constructors/regular-expression-literal.html" target="_blank">Regular expression literal</a> - try to use the shorter literal notation</li>
</ul>
</section>
<section id="function-patterns">
<h2>Function Patterns</h2>
<h3>API Patterns</h3>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/function-patterns/callback.html" target="_blank">Callback patterns</a> - when you pass function A to function B as a parameter, function A is a callback function</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/function-patterns/configuration-objects.html" target="_blank">Configuration objects </a>- keep control of function arguments and makes it easily configurable</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/function-patterns/returning-functions.html" target="_blank">Returning functions </a>- one function returns another function or create another function on-demand</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/function-patterns/currying.html" target="_blank">Currying</a> - used to create new functions dynamically by partially applying a set of arguments</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/function-patterns/partial-application.html" target="_blank">Partial application</a> - the process of fixing a number of arguments to a function, producing another function of smaller arity</li>
</ul>
<h3>Initialization patterns</h3>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/function-patterns/immediate-functions.html" target="_blank">Immediate functions</a> - syntax that enables function execution as soon as it is defined</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/function-patterns/immediate-object-initialization.html" target="_blank">Immediate object initialization</a> - this pattern is mainly suitable for one-off tasks</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/function-patterns/init-time-branching.html" target="_blank">Init-time branching</a> - branch code once during initlization initialization</li>
</ul>
<h3>Performance patterns</h3>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/function-patterns/memoization.html" target="_blank">Memoization</a> - use function properties to avoid repeated computation</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/function-patterns/self-defining-functions.html" target="_blank">Self-defining functions</a> - self-overwrite with new bodies to do less work from the second invocation and after</li>
</ul>
</section>
<section id="object-creation-patterns">
<h2>Object Creation Patterns</h2>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/object-creation-patterns/namespace.html" target="_blank">Namespace</a> - namespaces help reduce the number of globals required and avoid naming collisions or excessive name prefixing</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/object-creation-patterns/declaring-dependencies.html" target="_blank">Declaring Dependencies</a> - it's good to declare the modules your code relies on at the top</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/object-creation-patterns/private-properties-and-methods.html" target="_blank">Private Properties and Methods</a> - JavaScript doesn't have special syntax for private members, you can implement them using a closure</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/object-creation-patterns/revelation.html" target="_blank">Revelation Pattern</a> - it is about having private methods, which you also expose as public methods</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/object-creation-patterns/module.html " target="_blank">Module Pattern</a> - all the methods are kept private and you only expose those that you decide at the end</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/object-creation-patterns/sandbox.html" target="_blank">Sandbox</a> - it provides an environment for the modules to work without affecting other modules and their personal sandboxes</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/object-creation-patterns/static-members.html" target="_blank">Static Members</a> - public and private static members</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/object-creation-patterns/object-constants.html" target="_blank">Object Constants</a> - an implementation of a contant object provides set, inDefined and get methods</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/object-creation-patterns/chaining.html" target="_blank">Chaining Pattern</a> - it enables you to call methods on an object one after the other</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/object-creation-patterns/sugar-method.html" target="_blank">method() Method</a> - adding convenient funcationality to a language</li>
</ul>
</section>
<section id="code-reuse-patterns">
<h2>Code Reuse Patterns</h2>
<h3>Classical Patterns (patterns that should generally be avoided)</h3>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/code-reuse-patterns/cp1-default.html" target="_blank">The default pattern</a> - create an object using the Parent() constructor and assign this object to the Child()'s prototype</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/code-reuse-patterns/cp2-rent-a-constructor.html" target="_blank">Rent a constructor</a> - it borrows the parent constructor, passing the child object to be bound to this and also forwarding any arguments</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/code-reuse-patterns/cp3-rent-and-set-prototype.html" target="_blank">Rent and Set Prototype</a> - restricts object creation for a class to only one instance</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/code-reuse-patterns/cp4-share-the-prototype.html" target="_blank">Share the Prototype</a> - restricts object creation for a class to only one instance</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/code-reuse-patterns/cp5-a-temporary-constructor.html" target="_blank">A Temporary Constructor</a> - first borrow the constructor and then also set the child's prototype to point to a new instance of the constructor</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/code-reuse-patterns/klass.html" target="_blank">Klass</a> - generally a pattern that should be avoided unless one is more comfortable with class than prototype</li>
</ul>
<h3>Preferred Patterns</h3>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/code-reuse-patterns/prototypal-inheritance.html" target="_blank">Prototypal Inheritance</a> - objects inherit from other objects</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/code-reuse-patterns/inheritance-by-copying-properties.html" target="_blank">Inheritance by Copying Properties</a> - an object gets functionality from another object, simply by copying it</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/code-reuse-patterns/mix-ins.html" target="_blank">Mix-ins</a> - copy from any number of objects and mix them all into a new object</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/code-reuse-patterns/borrowing-methods.html" target="_blank">Borrowing Methods</a> - reuse one or two methods of an existing object without forming a parent-child relationship with that object</li>
</ul>
</section>
<section id="design-patterns">
<h2>Design Patterns</h2>
<h3>Creational</h3>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/design-patterns/builder.html" target="_blank">Builder</a> - constructs complex objects by separating construction and representation</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/design-patterns/factory.html" target="_blank">Factory method</a> - creates objects without specifying the exact class to create</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/design-patterns/singleton.html" target="_blank">Singleton</a> - restricts object creation for a class to only one instance</li>
</ul>
<h3>Structural</h3>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/design-patterns/decorator.html" target="_blank">Decorator</a> - dynamically adds/overrides behaviour in an existing method of an object</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/design-patterns/facade.html" target="_blank">Facade</a> - provides a simplified interface to a large body of code</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/design-patterns/proxy.html" target="_blank">Proxy</a> - provides a placeholder for another object to control access, reduce cost, and reduce complexity</li>
</ul>
<h3>Behavioral</h3>
<ul>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/design-patterns/chain-of-responsibility.html" target="_blank">Chain of responsibility</a> - delegates commands to a chain of processing objects</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/design-patterns/command.html" target="_blank">Command</a> - creates objects which encapsulate actions and parameters</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/design-patterns/iterator.html" target="_blank">Iterator</a> - implements a specialized language</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/design-patterns/mediator.html" target="_blank">Mediator</a> - allows loose coupling between classes by being the only class that has detailed knowledge of their methods</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/design-patterns/observer.html" target="_blank">Observer</a> - is a publish/subscribe pattern which allows a number of observer objects to see an event</li>
<li><a href="https://github.com/shichuan/javascript-patterns/blob/master/design-patterns/strategy.html" target="_blank">Strategy</a> - allows one of a family of algorithms to be selected on-the-fly at runtime</li>
</ul>
</section>
<section>
<h2><em>References</em></h2>
<ol>
<li>
The Essentials of Writing High Quality JavaScript<br />
<a href="http://net.tutsplus.com/tutorials/javascript-ajax/the-essentials-of-writing-high-quality-javascript/" target="_blank">http://net.tutsplus.com/tutorials/javascript-ajax/the-essentials-of-writing-high-quality-javascript/</a>
</li>
<li>
JSPatterns<br />
<a href="http://www.jspatterns.com/" target="_blank">http://www.jspatterns.com/</a>
</li>
<li>
jQuery Anti-Patterns for Performance & Compression<br />
<a href="http://paulirish.com/2009/perf/" target="_blank">http://paulirish.com/2009/perf/</a>
</li>
<li>
How DRY Affects JavaScript Performance<br />
<a href="http://velocityconf.com/velocityeu/public/schedule/detail/21634" target="_blank">http://velocityconf.com/velocityeu/public/schedule/detail/21634</a>
</li>
<li>
Object Oriented JavaScript<br />
<a href="http://www.packtpub.com/object-oriented-javascript/book" target="_blank">http://www.packtpub.com/object-oriented-javascript/book</a>
</li>
<li>
JavaScript Patterns<br />
<a href="http://shop.oreilly.com/product/9780596806767.do" target="_blank">http://shop.oreilly.com/product/9780596806767.do</a>
</li>
<li>
JavaScript: The Good Parts<br />
<a href="http://shop.oreilly.com/product/9780596517748.do" target="_blank">http://shop.oreilly.com/product/9780596517748.do</a>
</li>
<li>
Pro JavaScript Design Patterns<br />
<a href="http://jsdesignpatterns.com/" target="_blank">http://jsdesignpatterns.com/</a>
</li>
<li>
Essential JavaScript Design Patterns For Beginners, Volume 1.<br />
<a href="http://www.addyosmani.com/resources/essentialjsdesignpatterns/book/" target="_blank">http://www.addyosmani.com/resources/essentialjsdesignpatterns/book/</a>
</li>
<li>
Eloquent JavaScript<br />
<a href="http://eloquentjavascript.net/" target="_blank">http://eloquentjavascript.net/</a>
</li>
</ol>
</section>
</div>
<footer>
by <a href="http://twitter.com/#!/shichuan">@shichuan</a> from <a href="http://www.xigan.com">喜感网</a>
</footer>
<!-- JavaScript at the bottom for fast page loading -->
<script type="text/javascript">var switchTo5x=false;</script><script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">
stLight.options({
publisher:'44fc3536-fd12-4c07-970d-6654da9a2d6c',
st_url:'http://shichuan.github.com/javascript-patterns/'
});
</script>
<!-- Asynchronous Google Analytics snippet. Change UA-XXXXX-X to be your site's ID.
mathiasbynens.be/notes/async-analytics-snippet -->
<script>
var _gaq=[['_setAccount','UA-2773745-18'],['_trackPageview'],['_trackPageLoadTime']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
<!-- Prompt IE 6 users to install Chrome Frame. Remove this if you want to support IE 6.
chromium.org/developers/how-tos/chrome-frame-getting-started -->
<!--[if lt IE 7 ]>
<script defer src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
<script defer>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
<![endif]-->
</body>
</html>