Created
June 20, 2013 08:34
-
-
Save zmmbreeze/5821165 to your computer and use it in GitHub Desktop.
Detect javascript runtime environment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function DetectJSEnv() { | |
| if (typeof environment === 'object' && ({}).toString.call(environment) === '[object Environment]') { | |
| // Rhino | |
| // Details on how to detect Rhino: https://github.com/ringo/ringojs/issues/88 | |
| return 'rhino'; | |
| } else if (typeof(window) === 'undefined') { | |
| // Node.js | |
| return 'node'; | |
| } else { | |
| // Browser | |
| return 'browser'; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment