var animalList = [
{id_a: "bird", id_b: "t1"},
{id_a: "dog", id_b: "t2"},
{id_a: "cat", id_b: "t3"},
{id_a: "elephant", id_b: "t4"},
];
console.log(test(animalList));
function test(theList) {
var matchString = "cat"
var filter = (ele, index) => (ele.id_a === matchString || ele.id_b === matchString);
return theList.filter(filter);
}
如果我在var filter =
行设置了一个断点,并且步骤到最后一行我得到一个"未定义的过滤器属性"错误。如果我没有设置任何断点,它运行得很好。
这似乎是节点的问题,而不是代码。但我不知道为什么。 我正在使用vsCode进行调试。使用简单的配置启动节点调试。
{
"type": "node",
"request": "launch",
"name": "Launch Program custom",
"program": "${workspaceRoot}/app.js"
},
答案 0 :(得分:0)
我不得不将vsCode正在使用的调试协议更改为检查器而不是默认,我猜它是使用节点不再支持的遗留协议,而vsCode不够智能,无需帮助即可实现。