_js数组转json字符串">
赞
踩
数组转成json字符串 var arr = [1,2,3, { name : Jack } ]; JSON.stringify(arr); json字符串转成数组 JSON.parse(jsonStr); js 将数组转成逗号分隔的字符串 let arr = new Array(3); arr[0] = "Zero"; arr[1] = "One"; arr[2] = "Two"; let result = arr.join(",") console.log(result) //输出结果: => "Zero,One,Two" 1.数组转字符串 let list = [1,2,3,4,5,6]; list.join(","); console.log(list); // 打印结果:"1,2,3,4,5,6" 2.字符串转数组 var text = "1,2,3,4,5"; var array = text.split(",");//逗号是分隔符 var array = text.replace(/\"/g, "");
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。