Any ideas how to trigger the breakpoint inside a callback to Array.prototype.every?

270 Views Asked by At

I had followed this guide and installed chrome debugger (non related to the guide) on VS Code - I've modified index.tsx to contain this code:

function f(s:string) :boolean
{
    return s != undefined;
}

function f1()
{
    const v : string = String();

    if(v) {alert("IF");}

    const q = Array<string>(9);

    if(!q.every(f)) {alert("BOOLEAN");}
}

f1();

I've set a breakpoint inside f but it's never triggered. On the other hand is not being marked as grey while debugging. What am I missing?

Any breakpoint inside f1 is being triggered.

1

There are 1 best solutions below

0
On

Array<string>(9) creates an array with 9 empty slots, and the every method skips empty slots, so f is never called and a breakpoint set in f won't be reached.