@CodingComputing @JohnWritesCode_ @t3dotgg But there is no "something". The zero element for the minimum operation is +Infinity.
https://t.co/cRIe7ZbEo3
@NassauPopo@t3dotgg I hope you didn't mean `== true`. Because that basically equates to `== 1` (booleans always coerce to numbers in `==` comparisons), and that's definitely not the same as checking for truthiness.
@NassauPopo@t3dotgg I don't see how == would help here, because `undefined` would only return true for `== undefined` and `== null`. Comparing values of other types using `==` has even more complex rules.
However, coercing to boolean with `!!` would give `false` for both `0` and `undefined`.
@TheUnicornist@t3dotgg Sure, in TS, unless using `any` or some overloaded union types like `number | string`, == should be fine (apart from triggering my OCD).
Otherwise, I don't expect (trust?) that others remember all those coercion rules for ==. It's easy to get them wrong https://t.co/Y3jw4n2XXz
@bsides@t3dotgg Could you give an example of using `==` and explain what effect is desirable in that case? What do you mean "with empty strings"? Should they be falsy for you or not?
For booling I always use `!!`, and because there are only 7 falsy values in JS, I always know what to expect.
@dan_abramov Although I also try to allow myself for more simplicity and WETness in my code. I still have much to learn (and unlearn).
Visual tabularity of code is underrated IMO.
@dan_abramov You can't completely predict how requirements will change. So if they change, change the code.
In your clean example it is easier to analyze correctness and prove alignment with the reqs.
Repetitive blocks of math logic might obscure the connection between them and hide bugs.
@clyde_grey@JoshWComeau OTOH, normally I would write such reducer directly in place, so that the `.entries()` and `.reduce()` invocations and in close proximity, so that it is visible, what the arguments are. If I were to write a standalone reducer, I would probably make the variable names more verbose.
@clyde_grey@JoshWComeau I disagree in this specific case. If the scope is small, and the variable names follow some convention (here they do: k, v, and o are very often used with the meaning of key, value, and object, respectively), then it is permitted to use one-letter names. Context matters.
@JoshWComeau I believe there is a mistake in the re-written code example:
Instead of `output[Component] = Component;` there should be `output.Component = Component;`, similarly with `props`.
In the source snippet there is `{ ...o, [k]: v }`, not `{ ...o, [v]: v }`. `k` is a string.
THE BEST LEG OF ALL TIME! 🤯🔥
MICHAEL VAN GERWEN MISSES D12 FOR A NINE-DARTER, AND THEN SMITH PINS A PERFECT LEG HIMSELF!
ONE OF THE GREATEST THINGS YOU'LL EVER SEE IN SPORT.
@gearup_go_aaron You've probably noticed that, but if not, someone hacked your YouTube account and is currently streaming some crypto scam as Tesla Live. I hope you'll get it back soon.