weixin_39605326 2020-11-30 15:19
浏览 0

Closure variables hidden from debugger when using JS "module" pattern

Originally reported on Google Code with ID 2387


Closure variables hidden from debugger when using JS "module" pattern.

An example:

function context(){
    var list = [{test:1},{test:4},{test:6,abc:4}];

    return {
        Lookup:function(){
            // what is the value of list?
            debugger;
            var value = list[0];
            // value has a value, even though list does not
            // as seen in firebug
            return value;
        }
    }
}
var c = context();
var v = c.Lookup();

When the debugger stops, there is no value for list, even though when you
step over the next line, value does indeed get set. This makes debugging
code that is written in this pattern difficult.

Firebug 1.5a26+ (14 Oct 2009) on Fx 3.5

Reported by sroussey on 2009-10-15 17:57:21

该提问来源于开源项目:firebug/firebug

  • 写回答

5条回答 默认 最新

  • weixin_39605326 2020-11-30 15:19
    关注
    
    When I say "there is no value for list", I mean in the watch panel of the script
    panel. Even adding 'list' results in undefined.
    

    Reported by sroussey on 2009-10-15 17:58:32

    评论

报告相同问题?