Snippets / JavaScript

Useful patterns, kept close.

A small, searchable-ready home for reusable code. Add new entries as MDX files without touching the page layout.

JavaScript · Arrays

Remove duplicate objects by key

const uniqueBy = (items, key) =>
  [...new Map(items.map(item => [item[key], item])).values()];

Uses a Map to retain the latest object for each key and returns the unique values.

Ready for your library

Add more real snippets in content/snippets; the MDX structure and syntax-friendly styling are already in place.