Thoughts

mental health break ,./'"**^^$_---
You know what I think I want is ``` Array.prototype.filter = (function () { const oldFilter = Array.prototype.filter;
return function (f, ...args) { return oldFilter.bind(this)(f ? f : v => !!v, ...args); } })(); ``` Filtering for truthyness is a common operation when doing functional programming stuff. In JS I normally do it like `[1, false, 2].filter(v => !!v)`. (The `!!` is of course optional but I think it improves readability over the identity.) Ruby has a function for this called `.compact`, but I don't love that. I've been thinking about names and I just can't come up with something better. `.dropFasly()`, `.filterTruthy()`, `.removeUndefined()`, `.true()`? But honestly I think having it be a default behavior for `.filter()` makes a lot of sense. Although `Array.prototype.extant = function () { return this.filter(v => v !== undefined && v !== null) };` would be pretty nice.
Link 2:14 p.m. Oct 07, 2022 UTC-4