1

I would like to convert string formatted text into an array as follows. Source string is like:

var myString = "[3, 8750, "Some text, with commas"]";

Required result is as follows:

myArray[0] = 3;
myArray[1] = 8750;
myArray[2] = "Some text, with commas";

I will appreciate any kind of support..

Tolga
  • 1,307
  • 3
  • 16
  • 31

1 Answers1

1

Use JSON.parse() to change string formated value into to array.

var myString = "[3, 8750, \"Some text, with commas\"]";
let myStringList =JSON.parse(myString);
console.log(myStringList);
Mohammad Ali Rony
  • 4,695
  • 3
  • 19
  • 33