JS - Determine that an entry is unsaved?
Craft checks if a form has changed using javascript in the cp.js file, see line 196.

You could replicate this quite easily yourself though, here is a stripped down example:

var initialFormValues = $('form[data-confirm-unload]').serialize();

function checkFormChanged() {
    if ($('form[data-confirm-unload]').serialize() != initialFormValues) {
        return true;
    }

    return false;
}