how to print large array fully in chrome console?
30,483
Solution 1
just join all the elements, separated in string with "," :
uniqueNames.join("\",\"")
Solution 2
To print the full array in the console you can do :
console.log(JSON.stringify(uniqueNames))
Solution 3
I was looking for console.table(array):
Related videos on Youtube
Author by
static
Updated on April 24, 2021Comments
-
static about 3 years
I want to print an array (uniqueNames) in the Chrome Console:
> console.log(uniqueNames)
but the problem I come across is that after
> ["Theodor", "Albertus", /* 95 other elements */ "Andreas", "Bernd", "Roland"…] <--- dots here
How to print the full array like the first 100 elements? I want to copy it and use in another application. Or maybe it is possible to write this array from the Chrome Console to a file (also in one line, and not as whole log)?
-
static about 11 yearsWhy should I ask Google to change Chrome just for me? If one want format the output in bash, one format it and do not ask bash developers to change bash. I just want to find the way to format the output string. Actually, already found it. Yes - one possibility - to .append(uniqueNames), but it looks ugly (still unformatted)
-
-
Sebastian Dressler over 9 yearsThis does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.
-
fadomire over 9 yearsactually it is an answer, i reformulated to make it more clear
-
Sebastian Dressler over 9 yearsyes, but IMO this answer is not entirely correct, because
JSON.stringify
will not print a string but convert to a string. -
fadomire over 9 yearsoh, you are right i kind of misread and thought he wanted to print from console and not from the code. answer edited.
-
user1274820 almost 6 yearsMaybe you didn't answer the original question properly, but this is what most of us are looking for - thanks 😉
-
Jacques Mathieu about 5 yearsWorks, but leaves off the first and last quotation mark for me. Easy fix is just to use this:
"\"" + uniqueNames.join("\",\"") + "\""
-
nightowl over 3 yearsIf the array is large VS Code prints only part from the start and part from the middle. How can I print the whole array of 450 JSON Objects?
-
BaDr Amer over 2 years
console.log(JSON.stringify(uniqueNames, null, 2))
// for pretty format