基于输入参数的呼叫功能JavaScript
我们有一个脚本可以从CMD(易于槽指挥官,我们正在运行节点)获得输入,但是一旦有了此输入,如何设置数组? 例如,输入是“ Doge”,我想称呼一个dict的门槛元素。 我搜索并拖了窗口[]可以做到这一点,但是节点不是这样。
const { program } = require('commander');
program
.option('-p, --pair <type>', 'pair tocken to farm');
program.parse(process.argv);
const options = program.opts();
if (options.pair) console.log(`- ${options.pair}`);
if (options.pair=='MATIC,BANANA') {
console.log(options.pair.split(',')[0])
}
const pair = obj[options.pair]
console.log(pair)
var dict = {
Name: ["Eric","rodrigez"],
Age: 23,
Job: "Freelancer",
Skills : "JavaScript",
BANANA :"perfect"
};
console.log(dict.pair)
We have a script that gets input from the cmd (easy trough commander, we are running Node) but once we have this input how can set a array?
For example, the input is "doge" and I want to call the Doge element of a dict.
I searched and tought window[] could do this, but is not the case for node.
const { program } = require('commander');
program
.option('-p, --pair <type>', 'pair tocken to farm');
program.parse(process.argv);
const options = program.opts();
if (options.pair) console.log(`- ${options.pair}`);
if (options.pair=='MATIC,BANANA') {
console.log(options.pair.split(',')[0])
}
const pair = obj[options.pair]
console.log(pair)
var dict = {
Name: ["Eric","rodrigez"],
Age: 23,
Job: "Freelancer",
Skills : "JavaScript",
BANANA :"perfect"
};
console.log(dict.pair)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论