Saturday 13 May 2017

Simple Node program produces error only when stepping through it

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);

}

if I set a break point on var filter = line, and step to the last line I get a "no filter property on undefined" error. If I don't set any break points it runs just fine.

This seems to be a problem with node, rather than the code. But I don't know why. I am using vsCode to debug. With a simple configuration for launching node debugging.

    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program custom",
        "program": "${workspaceRoot}/app.js"
    },



via Volatile

No comments:

Post a Comment