argv(参数相关的)
/* argv argv0 execArgv execPath */ const { argv, argv0, execArgv, execPath } = process; argv.forEach(item => { console.log(item); }); console.log(argv0); console.log(execArgv); console.log(execPath);
env环境
const { env} = process
console.log(env);
cwd 打印出当前process可执行的路径
//打印出当前process可执行的路径 console.log(process.cwd());
timer
举个例子:
12_timer.js(一般情况用setImmediate)
process.nextTick比setImmediate执行得早
process.nextTick最快是因为把自己插入的function当前队列得最后一个
而setImmediate是把它插入下个队列的对=队首,而setTimeout放在两个中间
setImmediate(() => { console.log('setImmediate'); }) setTimeout(() => { console.log('setTimeout'); }, 0) process.nextTick(() => { console.log('nextTick'); })
运行结果: