JSPatterns.com

Hi and welcome to the javaScript patterns site. I used to have this site as a wiki, but received way more spam than I have time to deal with. I'll restart it probably as a blog. Below is the table of contents from the old site.

Thanks, Stoyan


= Patterns =

* Seperating behaviour
* Array and [[Object literals]]
* [[Singleton]]
* [[Singleton2]]
* Ways to implement [[inheritance]]
* [[Private]] variables and methods
* Events/subscribers
* [[Factory]]
* [[Namespaces]]
* [[Decorator]]
* Property caching
* [[Load-time branching]]
* The good "pageizen" - (function(){code here})()
* [[Configuration object]]
* Dynamic script tags
* JSON
* setTimeout for responsive pages
* [[chaining]]
* private functions as public methods
* borrowing methods from other objects using apply() and call()
* constructors that enforce new - if (this === window){return that;}
* mixins, multiple inheritance

= Anti-patterns =

* Globals - vars, functions
* Using global functions as class methods
* eval(), new Function(), setTimeout("do()", 1) as opposed to setTimeout(do, 1)
* document.write
* augmenting built-in objects
* with or without new