【发布时间】:2018-08-16 10:32:09
【问题描述】:
这段代码中的“i”和“f”是什么意思?它是如何定义的+代码如何知道它的文件名和文件数量?
if(err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js")
if(jsfile.length <= 0){
console.log("couldn't find commands.");
return;
}
jsfile.forEach((f, i) =>{
let props = require(`./commands/${f}`);
console.log(`${i} commands have loaded!`);
bot.commands.set(props.help.name, props);
});
【问题讨论】:
-
它正在编辑,我不知道我怎么忘记代码了哈哈
-
那么
jsfile是什么? -
f&i它们只是数组forEachfunction.Google 的数组 forEach 的参数,你会知道的
标签: javascript foreach