rwxes
rwxes

Reputation: 303

how to get nodejs process.arvg and above?

Been looking for the simplest way to capture argv[4] and any more after that?

$ node script.js foo bar la di da

var a = process.argv[2];
var b = process.argv[3];
var c = process.argv[?];

wanting to capture la di da .. was thinking >= or similar..? maybe forEach?

Upvotes: 0

Views: 66

Answers (1)

Dancrumb
Dancrumb

Reputation: 27529

If you mean that you want to capture the remaining arguments into a single variable, then try:

var c = process.argv.slice(4);

c will be a variable containing the remaining CLI parameters

Upvotes: 1

Related Questions