字符串按照-
分割成数组(字符串转数组)
var changeToArray = [];
var originalStr = "jianshu-coder-ZB";
changeToArray = originalStr.split('-');
console.log("内容:" + changeToArray + ",changeToArray的类型:" + typeof (changeToArray) + ",转成字符串:" + JSON.stringify(changeToArray));
数组按照,
分割成字符串(数组转字符串)
var changeToStr = "";
var originalArr = ['jianshu', 'coder', 'ZB'];
changeToStr = originalArr.join(',');
console.log("内容:" + changeToStr + ",changeToStr的类型:" + typeof (changeToStr) + ",转成字符串:" + JSON.stringify(changeToStr));