简体   繁体   中英

How do i convert an array of sub-array strings to an array of sub-arrays in javascript?

How do i convert an array in javascript , from this format :

["[1,2,3]","[4,5,6]"] to [[1,2,3],[4,5,6]] ?

i need to get an array of sub-arrays from my array of strings(in arrays format!)

thank you!

var input = ["[1,2,3]","[4,5,6]"];
var fullQualifiedArrayStructure = input.map(JSON.parse);

using map to apply a function to each element of the array. the applied function is JSON.parse, which converts a JSON string representation into an object.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM