NodeJS: command line arguments



examples/js/node_argv.js
console.log(process.argv);
console.log('--------------');
var i;
for (i = 0; i < process.argv.length; i++) {
    console.log(process.argv[i]);
}

$ node examples/js/nodejs_argv.js foo bar
[ 'node',
  '/Users/gabor/work/training/javascript/examples/js/nodejs_argv.js',
  'foo',
  'bar' ]
--------------
node
/Users/gabor/work/training/javascript/examples/js/nodejs_argv.js
foo
bar