There is probably a proper way to do this, but until then I'll just leave this ugliness for now:
var isEditForm = !!window.location.href.match(/editform\.aspx/i);
(Note custom forms will have a different url, so this is not a very good solution).
As commented by @PirateEric looking for ID querystring parameter is another option.
var isEditForm = !!window.location.search.match(/id=\d+/i)
As mentioned in comments
JSRequest.QueryString["ID"] can be used to get the ID querystring. It must first be initialized with
Another option is to use
GetUrlKeyValue. I have tested this on 2010, 2010 custom forms, 2013, 2013 custom forms, O365 and O365 with custom forms and it works in all.
This is the snippet I used:
var isEditForm = !!(GetUrlKeyValue('ID') || GetUrlKeyValue('id'));
ID is as far as I know always upper case, but it is best to be on the safe side.