Why doesn't console.log() take a snapshot of the passed variables?

后端 未结 3 1316
长发绾君心
长发绾君心 2020-12-31 01:59

I\'ve ran into some really weird behavior with javascript today. I think I got it somehow figured out now, but I\'d like to know if what I think is going on is really happen

3条回答
  •  攒了一身酷
    2020-12-31 02:52

    There is console.dir() for what you want in Firebug.

    In general, it is not possible to print every level of nested properties, since objects can contain circular references like var a = {}; var b = {a: a}; a.b = b;

    Implementing a perfect clone method is very hard - I guess it would have to basically just dump the whole memory, and logging would take awfully long. Think about console.log(window)...

提交回复
热议问题