JavaScript Design Patterns - p-patel/software-engineer-knowledge-base GitHub Wiki
https://app.pluralsight.com/library/courses/javascript-design-patterns/
Common Object Patterns
Function argument patterns
- missing arguments in a function call are
undefined
- additional arguments passed to a function call that are not defined as parameters are available from the
arguments
object that is available in all functions and is accessible like an array - e.g. flexibility of the default jQuery constructor which is implemented as a single function body
Chaining
- useful for creating flent APIs for working against a mutable object. Designed around returning the source object. Also common in .NET LINQ
- every function execution has an implicit return value
undefined
- capture the
this
object if the caller isn't trusted
Observable Properties
Creating Observable Properties
Observable Property Futures
Timer Patterns
Introduction
setTimeout()
andsetInterval()
- NB. delays < 4ms will bumped to 4ms
- Timers won't start until the outer-most function is finished
Timer Overview
- consider the timer stack