Array.prototype.push. It modifies the array in place, which is asking for trouble. It also returns the array length, not the modified array, which is plain confusing.
const original = ['cat', 'sat'] const modified = [...original, 'mat']
If you need to go old school, there’s
const original = ['cat', 'sat'] const modified = original.concat(['mat'])
Unless you’re dealing with a massive array, where memory usage is an issue. ↩
Sign up for my newsletter
A monthly round-up of blog posts, projects, and internet oddments.