数组转字符串
const arr=['h','e','l','l','o']
console.log("原数组:",arr)
const str=arr.map((item)=>item).join('')
console.log("转成的字符串:",str),
效果图:
字符串转数组
const str="hello"
console.log("原字符串:",str)
const arr=str.split('')
console.log("转成的数组:",arr)
字符串的切割
原字符串为hello,word 想截取word,
const str="hello,word"
console.log("原字符串:",str)
const arr=str.split(',')
console.log("转成的数组:",arr)
arr[1]就是想要的word