英文:
Is there a way to copy an array in the JavaScript console with every element being on the same line?
问题
我正在尝试通过JavaScript控制台复制一个包含100多个项目的大数组到剪贴板,我已经能够做到,但我遇到的问题是数组元素出现在不同的行上,就像这样:
[1,
2,
3,
4,
5, ...];
我想要的是将数组复制到剪贴板上的一行中,就像这样:
[1, 2, 3, 4, 5...];
英文:
I am trying to copy a large array of over 100 items to my clipboard through the JavaScript console, which I am able to do, but the problem I am having is that the elements appear on different lines like this:
[1,
2,
3,
4,
5, ...];
What I want is to copy the array to my clipboard in one line like this:
[1, 2, 3, 4, 5...];
答案1
得分: 1
使用JSON.stringify(array)
简单地打印出数组的字符串版本。
英文:
Simply print the string version of your array with JSON.stringify(array)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论