Files
30-seconds-of-code/snippets/isNode.md
Isabelle Viktoria Maciohsek 8bf67754ce Make expertise a field
2022-03-01 20:21:45 +02:00

578 B

title, tags, expertise, firstSeen, lastUpdated
title tags expertise firstSeen lastUpdated
Environment is Node.js node,browser intermediate 2020-10-12T20:01:21+03:00 2021-04-02T11:45:13+03:00

Determines if the current runtime environment is Node.js.

  • Use the process global object that provides information about the current Node.js process.
  • Check if process, process.versions and process.versions.node are defined.
const isNode = () =>
  typeof process !== 'undefined' &&
  !!process.versions &&
  !!process.versions.node;
isNode(); // true (Node)
isNode(); // false (browser)