我在注销对象内数组的内容时遇到问题。实际的物体看起来像这样
var stuff = { accepted: [ 'item1', 'item2' ],
rejected: [],
response: 'Foo',
envelope: { from: 'The sender', to: ['new item1', 'new item2'] },
messageId: 'xxxxxxxxxxxxx' } }
The console.log
显示第一个数组的项目很好,但第二个数组的输出为[Object]
.
{ accepted: [ 'item1', 'item2' ],
rejected: [],
response: 'Foo',
envelope: { from: 'The sender', to: [Object] },
messageId: 'xxxxxxxxxxxxx' } }
这里发生了什么以及当我如何显示第二个数组的项目console.log
。谢谢你的帮助!
UPDATE
抱歉,我忘了补充一点,我只在 Node.js 中工作,因此它是一个服务器端日志,需要准确地显示从回调中接收到的对象console.log
, IE。没有进一步的字符串化。
我也只是尝试创建另一个具有类似结构的随机对象。
var objText = {
fun: {
stuff: 'Some stuff',
list: ['this', 'it', 'takes']
}
};
The console.log
对于上面的是:
{ fun: { stuff: 'Some stuff', list: [ 'this', 'it', 'takes' ] } }
这对我来说似乎是相同的结构,但console.log
工作正常,因此在 Node 中似乎完全有可能记录数组内容,即使它嵌入在内部且对象位于外部对象内。