字符串按照-
分割成數(shù)組(字符串轉(zhuǎn)數(shù)組)
var changeToArray = [];
var originalStr = "jianshu-coder-ZB";
changeToArray = originalStr.split('-');
console.log("內(nèi)容:" + changeToArray + ",changeToArray的類型:" + typeof (changeToArray) + "鲜漩,轉(zhuǎn)成字符串:" + JSON.stringify(changeToArray));
數(shù)組按照,
分割成字符串(數(shù)組轉(zhuǎn)字符串)
var changeToStr = "";
var originalArr = ['jianshu', 'coder', 'ZB'];
changeToStr = originalArr.join(',');
console.log("內(nèi)容:" + changeToStr + "源譬,changeToStr的類型:" + typeof (changeToStr) + ",轉(zhuǎn)成字符串:" + JSON.stringify(changeToStr));
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者