Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用开发人员工具逐步实现javascript中的匿名函数_Javascript - Fatal编程技术网

使用开发人员工具逐步实现javascript中的匿名函数

使用开发人员工具逐步实现javascript中的匿名函数,javascript,Javascript,例如,我想检查名为“test”的变量 (function() { var test = function(){alert("hello");}; test(); })(); 添加断点是实现这一点的唯一方法吗,还是[chrome | javascript | developer tools]特有的忍者富?您可以尝试以下方法:- console.error(e); (function() { var test = function(){alert("hello"

例如,我想检查名为“test”的变量

(function() {
    var test = function(){alert("hello");};
    test();
})();   
添加断点是实现这一点的唯一方法吗,还是[chrome | javascript | developer tools]特有的忍者富?

您可以尝试以下方法:-

 console.error(e);

 (function() {
    var test = function(){alert("hello");};
     test();
     console.error(e);
  })();

或者
console.log(test)
:)你期待什么忍者富?我猜你的问题不是关于匿名函数
test
,而是关于IEFE中的局部变量
test
,不是吗?alert()和console.log()都会污染代码,我需要很多它们来做我在这里做的事情(通过检查其他人的代码来学习)。我希望有一些内置的技巧来查看范围外的变量。
(function() {
  var test = function(){alert("hello");};
  debugger;
  test();
})();