use*_*769 5 javascript debugging google-chrome higher-order-functions google-chrome-devtools
今天遇到了Google Chrome调试器的一个有趣问题.变量看起来不可用,但它是 - 只是调试器无法使用.这是一些示例代码:
<script>
var foo = function(passedInThing, otherPassedInThing) {
return {
bar: function() {
window.im_using = passedInThing;
debugger;
}
}
}
foo("this exists", "this does not").bar();
</script>
Run Code Online (Sandbox Code Playgroud)
因为我在内部函数的范围内引用了passInThing,所以调试器可以看到该变量并对其进行操作.但是在使用之前,otherPassedInThing似乎是不可见的.
据我所知,firefox似乎没有相同的限制.这是一个错误,还是有一些理由背后的原因?