How to find which item has been changed in APEX

Note: I previously had a similar post about this which I somehow lost so re-writing it. The original link was:

By default APEX will warn users when leaving a page. When users modify a page with input and try to close the tab or refresh the page they will be shown the following dialog (note: each browser will show a slightly different warning message):

The default options for this can be changed at the page level by toggling the Warn on Unsaved Changes option:

Alternatively you can control each page item to determine if it'll trigger a warn on unsaved message:

There are some times when you may want to manually determine if a page item has been modified. In JavaScript the apex.item object contains a function called isChanged() Using the new(ish) apex.items object (which contains all the page items) you can quickly identify which page items have been changed. The following function will return an array of APEX item names that have been changed:

Object.keys(apex.items).filter((key) => apex.items[key].isChanged());

Hayden Hudson has a neat snippet that shows some custom warnings when a page item has been changed.