Find JavaScript function definition in Chrome

前端 未结 11 2308
难免孤独
难免孤独 2020-11-28 17:16

Chrome\'s Developer Tools rock, but one thing they don\'t seem to have (that I could find) is a way to find a JavaScript function\'s definition. This would be super handy fo

11条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 17:53

    I had a similar problem finding the source of an object's method. The object name was myTree and its method was load. I put a breakpoint on the line that the method was called. By reloading the page, the execution stopped at that point. Then on the DevTools console, I typed the object along with the method name, i.e. myTree.load and hit Enter. The definition of the method was printed on the console:

    Also, by right click on the definition, you can go to its definition in the source code:

提交回复
热议问题