繁体   English   中英

有没有一种方法可以在命令行中使用带有节点的参数运行函数?

[英]Is there a way to run functions with parameters with node in command line?

如果我想运行一个简单的script.js,我只需要编写:

node script

但是,如果我想运行带有这样的参数的函数,例如:

function genRandNum(min, max) {
  let num = Math.floor(Math.random() * (max - min + 1)) + min;
  return num;
}

如何在此处传递参数? 编写node script(1, 10)在这里不起作用,有没有办法做到这一点?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM