Find JavaScript function definition in Chrome

前端 未结 11 2311
难免孤独
难免孤独 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:55

    Lets say we're looking for function named foo:

    1. (open Chrome dev-tools),
    2. Windows: ctrl + shift + F, or macOS: cmd + optn + F. This opens a window for searching across all scripts.
    3. check "Regular expression" checkbox,
    4. search for foo\s*=\s*function (searches for foo = function with any number of spaces between those three tokens),
    5. press on a returned result.

    Another variant for function definition is function\s*foo\s*\( for function foo( with any number of spaces between those three tokens.

提交回复
热议问题