0

I am a newbie in programming. I am trying to use JSZip to zip some files from HTML5 filesystem, and I found the following difference between JSZip and other kinds of objects. Could anyone explain this to me?

<script src="jszip.js" type="text/javascript"></script>
<script>
function a(){
    var x=new JSZip();
    console.log(x) //Strange, it shows a JSZip object with folder abc
    b();

    function b(){
        x.folder("abc");
        console.log(x) //also shows a JSZip object with folder abc
    }
}
a();

function c(){
    var y=new Array();
    console.log(y) //shows []
    d();

    function d(){
        y[0]="abc";
        console.log(y); //shows ["abc"]
    }
}

c();
</script>
MK Yung
  • 4,344
  • 6
  • 30
  • 35
  • 2
    Using chrome? http://stackoverflow.com/questions/8249136/why-does-javascript-object-show-different-values-in-console-in-chrome-firefox/8249333#8249333 – Alex K. Oct 01 '12 at 14:18
  • yes! so you mean its the problem of Chrome...? – MK Yung Oct 01 '12 at 14:40
  • http://stackoverflow.com/a/12682225/251311 + http://felix-kling.de/blog/2011/08/18/inspecting-variables-in-javascript-consoles/ – zerkms Oct 08 '12 at 06:46

1 Answers1

0

As Alex K. commented, this is a feature of the Webkit inspector.

If you change your console.log lines to console.log(JSON.stringify(x));, the object will be evaluated at that point, showing that the object contains the properties that you expect.

Community
  • 1
  • 1
Stuart K
  • 3,212
  • 4
  • 22
  • 27