const byTag = Object.groupBy(posts, (post) => post.tag)
// { webdev: [...], gamedev: [...] }
It's in all current browsers and Node 21+. Map.groupBy does the same but returns a Map, which you want when the keys aren't strings.
Where you can't rely on it yet, the reduce version is a few lines:
const groupBy = (items, key) =>
items.reduce((groups, item) => {
const k = key(item)
groups[k] ??= []
groups[k].push(item)
return groups
}, {})