## split()函数无参情况时:
当split无参时,表示将调用者整个字符串存入到数组中。

// 将整个字符串存到数组中
value='za,we,ds,aw'
value.split(); ==>["za,we,ds,aw"]


## split()函数参数为空字符串时:

// 将字符串中每个字符单独存到数组中
value='za,we,ds,aw'
value.split(''); ==>["z","a",",","w","e",",","d","s",",","a","w"]


## split()函数参数为指定字符串时:

// 按照指定字符串截取转换为数组
value='za,we,ds,aw'
value.split(','); ==>["za","we","ds","aw"]


## reverse()函数:
将指定数组倒序排序并返回

value='za,we,ds,aw'
value.split(',').reverse(); ==>["aw","za","we","ds"]


## join()函数无参时:

将指定数组中全部数据用','逗号连接转换为一个字符串
value='za,we,ds,aw'
value.split(',').reverse().join(); ==>"aw,za,we,ds"


## join()函数参数为空字符串时:

将指定数组中全部数据转换为一个字符串
value='za,we,ds,aw'
value.split(',').reverse().join(''); ==>"awzaweds"


## join()函数参数有参时:

将指定数组中全部数据按照指定字符连接,并转成一个字符串
value='za,we,ds,aw'
value.split(',').reverse().join('+'); ==>"aw+ds+we+za"

Logo

基于 Vue 的企业级 UI 组件库和中后台系统解决方案,为数万开发者服务。

更多推荐