Catching Cute Monsters with Immutable Patterns from Functional Programming
summary
A toy monster-collection app is built in vanilla JavaScript (webpack used) to compare object-oriented mutating code with immutable functional patterns; an initial bug shows leveling owned monsters unexpectedly mutates an opponent because both trainers share the same array reference, producing an unexpected tie. The fix uses Object.assign and spread for new objects and map/filter/reduce to produce new arrays and to sum levels; the final deterministic functions return new trainers/monsters and the battle result then matches the expected winner.
AI-written summary · about
chapters (9)
- 0:00Intro
- 0:15Overview
- 2:38Requirements
- 4:07Coding
- 13:45Visual Debugging
- 16:05Functionalism
- 19:38Object Assign
- 23:06Object Spread
- 31:29Final Code
related talks
53mMaintainable JavaScript with Functional Patterns
34mFunctional JavaScript for everyone
30mLearning Functional Programming with JavaScript
12mAn introduction to functional programming
01h 03mFunctional Programming in JS: What? Why? How?
41mFunctional programming: Give it a chance!
37mA Guide To Functional Programming
01h 03mFunctional Programming in JavaScript
