js中数组, JSON的与字符串的处理

1. JSON转字符串

var jsonStr = {"name": "xiaoming", "sex": "男"}
JSON.stringify(jsonStr)

2. 数组转字符串

var arr= ["A", "B", "C", "D"];
var str = arr.toString();       // Returns a string representing the specified object.
var str1 = arr.join()               // Joins all elements of an array into a string.

var str2 = arr.join(",");          // 给每个元素之间加入 "," 隔开,并转字符串
posted @ 2018-03-14 20:47  小鸣的微笔记  阅读(63)  评论(0编辑  收藏