Comment

Comment by disillusionist

I started using this pattern years ago and haven't looked back. React components are defined using a single properties param and it feels natural to extend the practice to other methods and helper functions that I write.

One nice unexpected side effect is that I end up with more consistency in variable naming when using a param object in order to benefit from object definition shortcuts.

ie I will usually write something like

  const firstName = getFirstName(); doTheThing({ firstName });
rather than

  const fName = getFirstName(); doTheThing({ firstName: fName });

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton