How to detect if we are in the Site Editor part of the Block Editor (as opposed to editing a Page/Post) in JavaScript?

The Block Editor, in both the context of the editing pages or the Site Editor, actually does provide some simple variables in JavaScript similar to the data that is available via get_current_screen in PHP.

Sample variables in Page Editor:

var ajaxurl="/mysite/wp-admin/admin-ajax.php",
pagenow = 'page',
typenow = 'page',
adminpage="post-new-php",
thousandsSeparator=",",
decimalPoint=".",
isRtl = 0;

Sample variables in Site Editor:

var ajaxurl="/mysite/wp-admin/admin-ajax.php",
pagenow = 'site-editor',
typenow = '',
adminpage="site-editor-php",
thousandsSeparator=",",
decimalPoint=".",
isRtl = 0;

So one can simply access ‘pagenow’ to make the determination which context we are in.