K
K
kr_ilya2019-09-20 20:03:54
JavaScript
kr_ilya, 2019-09-20 20:03:54

How to display a full array in the browser console or copy the value of a js variable?

You need to copy the values ​​from the variable with the array [1,2,3,4,5] But if you do console.log(variable) and there are more than 100 values ​​in the array, it is split and displayed with indices. You only need to copy the values ​​of the array. Maybe there is a way to display the entire array as text, as if it were in a regular editor, or for example copy the value of a variable to the clipboard with a javascript command?
Everything happens in the browser console

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Afanasy Zakharov, 2019-09-20
@kr_ilya

const textarea = document.createElement('textarea');
document.body.append(textarea);
textarea.value = your_array.toString();
textarea.select();
document.execCommand('copy')

and it will be on the clipboard

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question