Search code examples
javascriptarraysclient-side-scripting

JavaScript Get nested array (1 level) with quotes preserving numbers with console.log


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]]


Solution

  • You can use JSON.stringify and log that

    console.log(JSON.stringify([["[]",2,"c"],["d","e","f"]]))