The 𝗽𝗿𝗼𝗰𝗲𝘀𝘀.𝗮𝗿𝗴𝘃 method lets you natively parse command line arguments, without the need for any additional libraries.
It returns an array of strings containing all the args that were passed when launching the 𝗡𝗼𝗱𝗲𝗷𝘀 process.
The first and second args are reserved, here's what they mean:
First: Is the 𝗽𝗿𝗼𝗰𝗲𝘀𝘀.𝗲𝘅𝗲𝗰𝗣𝗮𝘁𝗵 which is the absolute path of the executable that started the 𝗡𝗼𝗱𝗲𝗷𝘀 process.
Second: Absolute path for the file currently being executed.
Did you learn something new today?
Like and share this post, and follow me for more!
Sorry but this is "get" not "parse". Parsing is when you get command line options. When you pass
script.js -xo --name=hello
and you get that you used option "x" and "o" and "name" with value "hello". You can read what is Parsing on Wikipedia.I've written NPM package for parsing command line called lily. But there is also well establish one called yargs and it's little friend yargs-parser.