What are environment variables and how do you use them in Node.js?
Instruction: Explain the purpose of environment variables in Node.js and how to utilize them.
Context: This question assesses the candidate's knowledge on using environment variables in Node.js for storing configuration settings outside of the application code.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Environment variables are process-level string settings exposed through process.env. They allow deployment configuration to vary without editing source code, but are not automatically encrypted or protected from every process, log or diagnostic tool.
Validate and convert values at startup. For example, the string "false" is truthy in JavaScript, so Boolean(value) is usually the wrong parser for an environment string...