标签:字符串 bsp controls var play control sele merge split
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"] 数组
js 数组,字符串,json互相转换(在select实现多个输入的时候与后台交互常使用)
标签:字符串 bsp controls var play control sele merge split
原文地址:https://www.cnblogs.com/DZzzz/p/9678701.html