How to set a breakpoint at a lambda call in Google Chrome DevTools?

て烟熏妆下的殇ゞ 提交于 2019-12-05 00:13:05

This feature is finally available (at least in Google Chrome 58). Click on the line number of the line of your lambda you like to debug (here line 3). Then activate the marker in your lambda (here the second) by clicking it. Further, I disabled the first marker here, which would pause on the map call (not the lambda):

When your program runs and hits the breakpoint, it will pause and you can inspect variables:

shyam

You can use the debugger keyword to signal the debugger to pause at that location and it can be inserted just like any JavaScript statement.

function myFunc(elements) {
  return elements
    .map(element => {debugger; return element.value})
    .filter(value => value >= 0);
}

You can do as follows:

    function myFunc(elements) {
      return elements
        .map(element => {
           element.value
        })
        .filter(value => value >= 0);
    }

This way you can add a breakpoint in line element.value

Couldn't find a way to get it work without code changing.
If anybody can find a way please tell.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!