小程序中字符串转数组如何实现

JS 字符串转数组:

var words =' likely, likely, likely,economic, economic';     //字符串中间已特殊符号隔开

var words = words.split(",");    //转成数组类似php的explode函数

 

JS 字符串去重:

function unique (array){

return array.filter(function(el, index, arr) {

return index == arr.indexOf(el);

});

}

 

欢迎关注,有问题一起学习欢迎留言、评论。

原文地址:https://www.cnblogs.com/lovebing/p/9177585.html