JavaScript the Better Parts (Douglas Crockford)
- https://youtu.be/XFTOG895C7c
- The Better Parts. Douglas Crockford. JS Fest 2018
- Aug 12, 2019
- Fest Group
Summary of Douglas Crockford JavaScript Better Parts
Pre-JS2015
- stop using Operator “new”
- stop using Object.create
- stop using this Binding
- stop using null
- stop using “falsiness”. (do not use Double Equal Operator, use Triple Equal Operator, and make sure in if statement, the test always return true/false (boolean) )
- stop using for-loop 〔see for while do Loop〕
- stop using for-in Loop. Use forEach
- stop using
while
statement. Use tail recursion.
Crockford's JS2015 Bad Parts
- Never use Class. (misleading prototype object system with class object system.)
- Proxy (says its too complex.)
- Generator. (says its not necessary, complex, and confusing syntax.)
- Iterator
- Symbol
- Reflect (says its confusing and complex.)
- Arrow Function. (says the syntax is confusing, looks like relation. And the wart of returning a object must have
return
.)
Crockford's JS2015 Good Parts
Douglas Crockford JavaScript object system
- Traditional class object system (e.g. Java) is inflexible, no multi-inheritance (OOP diamond problem), hard to get the hierarchy correct, and impossible to change later.
- Crockford used to like JavaScript prototype object system. But not today. Never actually seen changing parent useful. Suffer from slow performance.
Crockford recommend a object system, written this way: