i have the below array:
let arr= ["5,5", "Orange", "6,1"];
Every item in that arr is random string and contains any character (","
,";"
,...")
For some reasons, i have to convert arr
to string.
I used let s = arr.toString()
and got the string: s= "5,5,Orange,6,1"
The problem is: I have to convert that string back to the array without reusing arr
and losing the format. If i use string.split(",")
, the result is ["5", "5", "Orange", "6", "1"]
instead of ["5,5", "Orange", "6,1"]
i know toString()
is the same to join array with ","
, but if i use arr.join()
with other character then split()
, it seems silly because item in arr is random and can contain any character.
Thanks a lot!