The script above grabs the third item in process.argv. Since the first two are always provided, the third item is the first command line argument that was passed in. The script uses the value of that argument to figure out what it should do.
1
2
node app.js add
# Adding note!
We can add command line options as well. But, if it’s done with argv, we’d need to parse them. We can instead use
yargs or
commander, packages built for this purpose.