Magento2 - Where do I put JS?

There are lots of JS examples on the website, but it doesn’t say anywhere where to put the JS file.

For example, there is a JS snippet:

instantsearch.widgets.hits({
  transformItems(items) {
  ...

But I have no clue where to put this file.