Safer JavaScript with the Maybe Type
Course on egghead by Andy Van Slaars
- 50 min
- LengthVideo runtime
- Subscription
- Price modelegghead plan
- 12
- Lessons
- 3.8
- Rating out of 56 ratings on egghead
- May 2018
- Published7 May 2018
About this course
JavaScript’s dynamic typing makes it incredibly flexible. That flexibility can lead to trouble though. When values have the potential to change types or to end up as null or undefined , that can lead to runtime errors in our code or bizarre bugs that take forever to track down because of type coercion. To battle this, we end up with code that is littered will conditionals for null or undefined values and type checks, making the core logic harder to read and refactor later. The Maybe encapsulates the type checking and guards against missing values for us. With Maybe in our toolbelt, we can keep our functions free of all the guardrails, outsource that work to the Maybe and keep our business logic free of all the clutter.
What it covers
- 1Course Introduction: Safer JavaScript with the Maybe type
- 2Understand the Maybe Data Type
- 3Create a Maybe with a `safe` Utility Function
- 4Unwrap Values from a Maybe
- 5Safely Access Object Properties with `prop`
- 6Safely Access Nested Object Properties with `propPath`
- 7Flatten Nested Maybes with `chain`
- 8Recover from a Nothing with the `alt` method
- 9Recover from a Nothing with the `coalesce` Method
- 10Compose Functions for Reusability with the Maybe Type
- 11Apply a function in a Maybe context to Maybe inputs
- 12Make your own functions safer by lifting them into a Maybe context
Similar JavaScript courses
Same topic, nearest in length, up to three from any one provider.
Data read from the egghead catalogue on 28 Nov 2026. How the data is collected.