I am trying to print out this code in a string.
var x = [[1, 2, 3, 4.5, 6], [7, 8.5, 9.5, 10]];`
console.log(x.toString());
This is what shows up.
When I print out the regular string, like so-
console.log(x);
This is what shows up-
Is there any way I can print out a string with the square brackets? I want the result to be something like "[[1, 2, 3, 4.5, 6], [7, 8.5, 9.5, 10]]".
I need to add this value to a eval function, which is why I need to add the entire array (as a string with the brackets) to the function.
Is there any way this can be possible (preferably without additional libraries)?


eval?evalto assign it to a variable instead of just assigning the array to the variable? I know thatevaldoesn't have to do with your specific question, but I'm thinking it's a possible XY problem.