对象转数组/*数组转字符串*//*字符串转换数组*/

/*对象转数组*/
var shu={name:'张三',age:20,gender:'男'};
console.log(shu);
function transform(obj) {
var arr = [];
for ( var item in obj) {
arr.push(obj[item]);
}
return arr;
}
var test1=transform(shu);
console.log(test1);

/*数组转字符串*/

var tt=['aa','bb','cc','dd','ee','ff'];
var tt1=tt.join(',');
console.log(tt1);

/*字符串转换数组*/
var s = "abc,abcd,aaa";
ss = s.split(",");// 在每个逗号(,)处进行分解。
 
原文地址:https://www.cnblogs.com/cx709452428/p/5790031.html