Due to the fact that most pattern categories have been added to the collection, future roundups will only come when there is significant amount of updates.
Juriy “kangax” Zaytsev has put very detailed research findings about named function expressions. As it says on the github site: In a nutshell, named function expressions are useful for one thing only — descriptive function names in debuggers and profilers. It has been added to Function Declarations.
Code reuse patterns discussed in Stoyan’s JavaScript Patterns have been added:
Classical Patterns (patterns that should generally be avoided)
- The Default Pattern – create an object using the Parent() constructor and assign this object to the Child()’s prototype
- Rent a Constructor – it borrows the parent constructor, passing the child object to be bound to this and also forwarding any arguments
- Rent and Set Prototype – restricts object creation for a class to only one instance
- Share the Prototype – restricts object creation for a class to only one instance
- A Temporary Constructor – first borrow the constructor and then also set the child’s prototype to point to a new instance of the constructor
- Klass – generally a pattern that should be avoided unless one is more comfortable with class than prototype
Preferred Patterns
- Prototypal Inheritance – objects inherit from other objects
- Inheritance by Copying Properties – an object gets functionality from another object, simply by copying it
- Mix-ins – copy from any number of objects and mix them all into a new object
- Borrowing Methods – reuse one or two methods of an existing object without forming a parent-child relationship with that object



俺觉得js还是不要搞什么模式好,为啥?js灵活啊,你却用一个个模式去套它?累不再说,没那必要……脚本还是灵活的脚本……
在制作应用时,模式还是很管用的。