view parameters passed to JavaScript function in Chrome

≯℡__Kan透↙ 提交于 2019-12-30 10:03:46

问题


I'm using Timeline in Chrome Developer Tools to help write a userscript. The timeline shows which functions are called, but not what values are actually passed to the parameters:

Is there a way to view the actual function that was run, including its values? I'm looking for any solution that will help me do this, even outside of Chrome.


回答1:


Open Sources tab at DevTools, select Snippets tab at left, right-click and select New, place text of function in middle window, return arguments from defined function, select text of function in middle window, right-click and select Add to Watch . At right window at Watch Expressions selected named function should be listed on left followed by how function is called, e.g., fn("abc", "def") followed by : Arguments[n] indicating and listing arguments passed to function where n is number of arguments passed; e.g., Arguments[2] for fn("abc", "def")



来源:https://stackoverflow.com/questions/35086894/view-parameters-passed-to-javascript-function-in-chrome

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