Reputation: 3
How can I take something in the form of
[["[]",2,"c"],["d","e","f"]]
and log
[["[]","2","c"],["d","e","f"]]
to the console? I have tried console.log(array.toString()) but that just logs
[[[],2,c],[d,e,f]]
Upvotes: 0
Views: 138
Reputation: 1503
This will preserve the arrays and only turn the the inner array items into strings.
var data = [["[]",2,"c"],["d","e","f"]];
var stringed = data.map((d)=>{
return (d.toString().split(","))
});
console.log(stringed);
Upvotes: 0
Reputation: 131
If u want to preserve double quotes "
then you can use
console.log(${'[["[]",2,"c"],["d","e","f"]]'}
)
else u can use
console.log(JSON.stringify([["[]",2,"c"],["d","e","f"]]))
Upvotes: 0
Reputation: 1629
You can use JSON.stringify
and log that
console.log(JSON.stringify([["[]",2,"c"],["d","e","f"]]))
Upvotes: 3