“process.argv” Code-Antworten

Knotenauslaufparameter

var args = process.argv.slice(2);
GutoTrosla

process.argv

>>node myprogram.js firstarg secondarg

process.argv[0] == "path/to/node"

process.argv[1] == "path/to/myprogram.js"

process.argv[2] == "firstarg"

process.argv[3] == "secondarg"

//process.argv[0] same as process.argv.slice(0)
Ian Selley

Node.js process.argv

// Command line values: node web.js testing several features
console.log(process.argv[2]); // 'features' will be printed
Magnificent Monkey Adi

process.argv

process.argv.slice(2).reduce((processArgs, val) => {
 let [key, value] = val.split('=');
 processArgs[key] = value;
 return processArgs;
}, {})
Alert Anaconda

Ähnliche Antworten wie “process.argv”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen