[英]view parameters passed to JavaScript function in Chrome
I'm using Timeline in Chrome Developer Tools to help write a userscript.我在 Chrome 开发者工具中使用时间线来帮助编写用户脚本。 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?有没有办法查看实际运行的 function,包括它的值? I'm looking for any solution that will help me do this, even outside of Chrome.
我正在寻找任何可以帮助我做到这一点的解决方案,即使是在 Chrome 之外。
Chromium does not list function arguments
with the other function parameters, or in any of the closure sections. Chromium 没有列出 function
arguments
和其他 function 参数,或者在任何闭包部分。
The arguments passed to a function are placed into a local property called arguments
.传递给 function 的 arguments 被放入名为
arguments
的本地属性中。 This property is an array
.该属性是一个
array
。
There are 2 ways to view them at a breakpoint.有两种方法可以在断点处查看它们。
Open the console, and type arguments
.打开控制台,然后键入
arguments
。 Then press enter
.然后按
enter
。
Open the watch panel
in the debugger, and enter arguments
as a watch item.在调试器中打开
watch panel
,输入arguments
作为监视项。
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
. 在
DevTools
Open Sources
选项卡中,选择左侧的Snippets
选项卡,右键单击并选择New
,在中间窗口中放置函数文本,从定义的函数返回arguments
,在中间窗口中选择函数文本,右键单击并选择Add to Watch
。 At right window at Watch Expressions
selected named function should be listed on left followed by how function is called, eg, fn("abc", "def")
followed by : Arguments[n]
indicating and listing arguments
passed to function where n
is number of arguments
passed; 在
Watch Expressions
右侧窗口中,应该在左侧列出所选择的命名函数,然后是如何调用函数,例如, fn("abc", "def")
后跟: Arguments[n]
指示和列出传递给函数的arguments
,其中n
是传递的arguments
数量; eg, Arguments[2]
for fn("abc", "def")
例如,
fn("abc", "def")
Arguments[2]
fn("abc", "def")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.