UWP supports "background tasks", which run in the background, for example in response to some system event or to implement an App Service.
JavaScript-based UWP apps declare background tasks in their respective application manifest files (.appxmanifest).
What is the best practice to detect whether my code is running as a background task?