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]]
您可以使用JSON.stringify
并记录JSON.stringify
console.log(JSON.stringify([["[]",2,"c"],["d","e","f"]]))
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"]]))
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.