Many friends who are familiar with JS have encountered the conversion of JS arrays and strings. This article will give a brief introduction to this, and the example is as follows:
1. Array to string
You need to concatenate array elements into strings with a certain character. The example code is as follows:
var a, b;a = new Array(0,1,2,3,4);b = a.join("-");2. To string to array
The implementation method is to cut a string into several strings according to a certain character and return it in an array. The example code is as follows:
var s = "abc,abcd,aaa";ss = s.split(",");// Decompose at each comma (,).