> ary = new Array('test msg kinda long but gets the point across and such and it shows ellipsises after a certain point in my test. test msg kinda long but gets the point across and such and it shows ellipsises after a certain point in my test. test msg kinda long but gets the point across and such and it shows ellipsises after a certain point in my test. test msg kinda long but gets the point across and such and it shows ellipsises after a certain point in my test. test msg kinda long but gets the point across and such and it shows ellipsises after a certain point in my test.');
> JSON.stringify(ary)
"["test msg kinda long but gets the point across and such and it shows ellipsises... (length: 116)"
我确实想要完整的对象,但 Chrome 希望将结果截断为大约 80 个字符。我没有在控制台设置中看到任何可以改变这一点的内容。
答案1
我最近发现 Chrome 开发工具有一个copy
功能,可以复制到剪贴板 - 不会截断!它还可以将对象序列化为 JSON,将 DOM 元素序列化为 HTML,直接复制到剪贴板。
copy(someLongString); // no truncation!
copy({ foo : true }); // JSON
copy(someDOMElement); // HTML
由于我试图将长字符串复制到剪贴板以便在其他地方进行分析,因此这完全满足了我的需求
2021 年编辑:似乎 Chrome 现在在控制台中添加了一个方便的按钮,用于复制长字符串:
以下是一些测试该功能的代码:
var str = "";
// generate 30kb hex string
for(var i = 0; i < (1024 * 30); i++) {
str += (i % 16).toString(16)
};
// just so we know it copied the whole thing
str += "END";
答案2
console.dir(longstringhere)
作品。
copy
对我来说也不起作用,它说的是undefined
。
答案3
此行为在 Chrome 版本 37.0.2062.103 中仍然存在。
您可以在调试时使用以下方法解决此问题:document.write('My Really Long Debug Text');
答案4
将 Chrome 升级到 32 版后就不会再出现这种情况了,如下图所示: