简体   繁体   English

在控制台中修改本地JavaScript变量

[英]Modifying local javascript variables in the console

If a page has code that wraps all variables in a scope, like this: 如果页面具有将所有变量包装在范围内的代码,如下所示:

$(function() {
    var attempts = 3;
});

Is it possible to edit the variables inside that scope from the browser console (eg Developer Tools for Chrome or Firebug for Firefox)? 是否可以通过浏览器控制台在该范围内编辑变量(例如,Chrome的开发人员工具或Firefox的Firebug)?

Yes, just set a breakpoint. 是的,只需设置一个断点。 Upon reaching the breakpoint you can modify all variables that are in scope at the breakpoint - including those hidden within closures. 到达断点后,您可以修改该断点范围内的所有变量-包括隐藏在闭包中的变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM