Find JavaScript function definition in Chrome

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

    You can print the function by evaluating the name of it in the console, like so

    > unknownFunc
    function unknownFunc(unknown) {
        alert('unknown seems to be ' + unknown);
    }
    

    this won't work for built-in functions, they will only display [native code] instead of the source code.

    EDIT: this implies that the function has been defined within the current scope.

提交回复
热议问题