Detect the current JavaScript runtime with compile-time optimization
This function is designed to be tree-shaken and optimized by bundlers. It checks for runtime-specific global objects in order of preference.
The detected runtime identifier
const runtime = detectRuntime();console.log(`Running on ${runtime}`); Copy
const runtime = detectRuntime();console.log(`Running on ${runtime}`);
Detect the current JavaScript runtime with compile-time optimization
This function is designed to be tree-shaken and optimized by bundlers. It checks for runtime-specific global objects in order of preference.