如何获得已优化的变量的值? [英] How get value of variable that has been optimized out?

查看:137
本文介绍了如何获得已优化的变量的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行Javascript期间,可以优化"某些变量.因此,此类变量的值在调试时无法检查(用户文档).变量视图显示(已优化)消息,如果尝试评估该变量,则控制台将引发以下错误:

Some variables can be "optimized out" during Javascript execution. Thus values of such variables are not available for inspection while debugging (User documentation). Variables view shows (optimized away) message and console throws following error if the variable is tried to be evaluated:

Error: variable has been optimized out

是否可以在Firefox中强制执行此类变量的评估或禁用此优化?

Is there any way to enforce evaluation of such variable or disable this optimization in Firefox?

推荐答案

以防止这种优化的方式使用变量.

Use the variable in a way that prevents this optimisation.

function NOP() {}

// then in the optimised code

    NOP(myvar);
    // debugging here should now show `myvar`

这篇关于如何获得已优化的变量的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆