1
我指的是我的生成器方法module.exports
但它的arguments
module
数组不是被调用的函数。模块参数覆盖函数参数
const Promise = require('bluebird');
const inc = Promise.coroutine(function* (model, condition, fields, options = {}) {});
module.exports = {
inc: (model, condition, fields, options = {}) => {
//reveiving all the arguments fine
return inc.apply(null, arguments); //but "arguments" array contains the values of "module", not the function
}
};
arguments
阵列:
0 - require function
1 - Module
2 - file path
3 - directory path
我得到了它的工作,但我不明白的问题。你能解释你的第一行**箭头函数不绑定参数对象**吗? – Shaharyar
'arguments'不能用于箭头来引用它们的参数,'arguments'指父函数作用域参数(在你的情况下是模块函数) - 与箭头中的this相似。被链接的参考文献解释了这一点。 – estus
我明白'arguments'属于父函数范围*(链接中也有解释)*,但我不明白箭头函数不能/不能有'arguments'。如果箭头函数是父项,该怎么办?我只是检查了制作箭头函数parent并收到了'arguments'对象.. – Shaharyar