Function detectEnvironment

    • Detects the current JavaScript runtime environment

      Performs comprehensive checks to identify whether the code is running in:

      • React Native (mobile app)
      • Browser (web app)
      • Node.js (server/CLI)
      • Unknown environment

      This is useful for conditional behavior based on platform capabilities.

      Returns Environment

      The detected environment type

      const env = detectEnvironment()
      if (env === 'browser') {
      // Use browser-specific APIs
      } else if (env === 'node') {
      // Use Node.js-specific APIs
      }

      isBrowser, isNode, isReactNative for specific checks