0

在 google chrome 调试器控制台上:

var array = ['item1'];
array //will print ["item1"]

Object.defineProperty(array, '1', {get: function(){return 'item2';}, set: function(v){}});
array //will print nothing

有没有办法让最后一行打印一些信息?console.log(array) 也只是打印 ['item1']。我只需要它来进行调试。

这实际上在 Firefox 中运行良好。在 Safari 中,我得到 ["item1", undefined × 1]。

4

1 回答 1

2

如果您使用的是 chrome,请尝试 console.dir(array)。

于 2013-11-04T00:42:36.573 回答