数组转字符串
var arr = [1,2,3,4,'巴德','merge'];var str = arr.join(',');console.log(str); // 1,2,3,4,巴德,merge
字符串转数组
var str = '1,2,3,4,巴德,merge';var arr = str.split(',');console.log(arr); // ["1", "2", "3", "4", "巴德", "merge"] 数组console.log(arr[4]); // 巴德
字符串转数组,数组转数组格式化,数组格式化转数组
var str = '1,2,3,4,巴德,merge';var arr = str.split(',');var strify = JSON.stringify(arr);console.log(arr); // ["1", "2", "3", "4", "巴德", "merge"] 数组console.log(arr[4]); // 巴德console.log(strify); // ["1", "2", "3", "4", "巴德", "merge"] 字符串var arrParse = JSON.parse(strify);console.log(arrParse); // ["1", "2", "3", "4", "巴德", "merge"] 数组
基础知识点,记录下来,方便查看。