下面的 linting 会提示“未使用”已定义但从未使用过。
function foobar( unused, used ) { return used }
在 Ruby 中,你可以做到
def foobar( _unused, used)
used
end
使用“_”表示未使用“未使用”,仅作为方法签名中的参数。是否可以在 javascript 中执行此操作?
最佳答案
如果您使用的是 ESLint,则可以在函数定义上方使用 //eslint-disable-next-line
来避免此 linting 错误。
关于Javascript参数忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57148888/