Node.js · Junior · Question 47 of 75
How do you read an environment variable PORT?
- ✓Correct answer:
process.env.PORT - 2
process.argv.PORT - 3
env.get("PORT")
Explanation
Values in process.env are always strings (or undefined), so convert them: Number(process.env.PORT ?? 3000).