https://github.com/fbeline/design-patterns-JS/tree/master/src
creates objects through functions
the new
keyword:
- Creates a brand new object
- Links to an object prototype
- Binds
this
to the new object scope. Implicitly returnsthis
object literal
- simple way to encapsulate methods
- creates a toolbox of functions to use
simplifies object creation
- Simplifies object creation
- Creating different objects based on need
- Repository Creation
Used to restrict an object to one instance of that object across the application.
- Remembers the last time you used it
- Hands the same instance back
- Node.js uses CommonJS
- 💪🏻 Motivation
- ✍🏻 Notation
- 👀 Examples
[]
is equal![]
true
is not equal![]
, but not equal[]
too- true is false
- baNaNa
NaN
is not aNaN
Object.is()
and===
weird cases- It's a fail
[]
is truthy, but nottrue
null
is falsy, but notfalse
document.all
is an object, but it is undefined- Minimal value is greater than zero
- function is not a function
- Adding arrays
- Trailing commas in array
- Array equality is a monster
undefined
andNumber
parseInt
is a bad guy- Math with
true
andfalse
- HTML comments are valid in JavaScript
NaN
isnota number[]
andnull
are objects- Magically increasing numbers
- Precision of
0.1 + 0.2
- Patching numbers
- Comparison of three numbers
- Funny math
- Addition of RegExps
- Strings aren't instances of
String
- Calling functions with backticks
- Call call call
- Object as a key of object's property
- Accessing prototypes with
__proto__
`${{Object}}`
- Destructuring with default values
- Dots and spreading
- Labels
- Nested labels
- Insidious
try..catch
- Is this multiple inheritance?
- A generator which yields itself
- A class of class
- Non-coercible objects
- Tricky arrow functions
- Arrow functions can not be a constructor
arguments
and arrow functions- Tricky return
- Chaining assignments on object
- Accessing object properties with arrays
Number.toFixed()
display different numbersMath.max()
less thanMath.min()
- Comparing
null
to0
- Same variable redeclaration
- Default behavior Array.prototype.sort()
- resolve() won't return Promise instance
{}{}
is undefinedarguments
binding- An
alert
from hell - An infinite timeout
- A
setTimeout
object - Double dot
- Extra Newness
- Why you should use semicolons
- A stringified string
- Non-strict comparison of a number to
true
- 📚 Other resources