Let's learn about anti-symmetry by solving this interview puzzle: "Move all zeros of an array of integers to the end while maintaining the relative order of all non-zeros."
I finally found a good use case for
z.object().strict() in Zod.
Node-Cache (a JS library) has generic
but it's easy to accidentally misuse them.
I made a type-safer wrapper around the library.
When parsing data,
date strings should likely be converted to
But beware mutations.
Parsing encompasses validation, plus it can increase type-safety, plus it can transform the data to a better format. Parse, don't just validate.
A little helper function to retry a function automatically a limited number of times (or until success) and with a certain delay between retries. Useful e.g. when working with a flaky API.
Huh. But if the array has 2+ items, attempting to sort it will cause a TypeError.
<button> element defaults to
which can cause accidental form submissions.
type="button" the default in your Button component
to make your life easier.
The TypeScript compiler could help prevent "illegal invocation" errors at compile time, at least theoretically.
To handle internal link clicks when using
attach click event listeners to the rendered links.
In the listener, push the link to the browser history.
What's that, a file extension named after me?! Or a file extension for TypeScript files that are always ES modules?
logical OR assignment operator (
I.e. props that depend on other props. You can require and forbid certain prop combinations by utilizing TypeScript's union and intersection types.
"Parameter properties" reduce boilerplate in classes, but they can also make the code hard to read.
default cases are confusing
but perfectly valid.
Sometimes it makes sense to place them at the beginning or in the middle.