Detect if JS is running under Node

Adam K Dean - Jul 2 '14 - - Dev Community

Here is a snippet for how to detect if JavaScript is running under Node:

var isNode = typeof process !== "undefined" && 
    {}.toString.call(process) === "[object process]";

We check here whether the variable process is defined, and if it is, we check it's type to make sure it's the proper process object and not just a regular old JavaScript object.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player