FP

Array handling in JS with functional purity

Functional programming has influenced JavaScript style significantly over the last decade. Pure functions — those that produce no side effects and return the same output for the same input — are now a widely adopted convention. But JavaScript is not a pure functional language, and the path to purity with composite types like arrays and objects has some real nuance worth understanding before you reach for a pattern wholesale.

TLDR

Clone before mutating when your function receives an array or object and side effects would be a problem. Prefer shallow clones for flat structures; reach for deep clones only when you have nested data you genuinely need to isolate. Don’t clone for read-only operations — it’s unnecessary cost with no defensive benefit.

Read more →

Toxic bias in the Javascript community

Having been in the Javascript community for a while I’ve witnessed the building momentum towards a Functional Programming (FP) style. I think Javascript and FP are great but there is perhaps a misguided favor or emphasis put on FP as something superior. The React community help perpetuate this with the introduction of hooks, moving away from class based components (favoring functions) and libraries like Redux all employing bits of FP.

Read more →