js中的join()与split()函数的区别和用法


let s = Array('a','p','p','l','e')
     s.join('')
"apple"
let s = Array('a','p','p','l','e')
     s.join(' ')
"a p p l e"
let s = Array('a','p','p','l','e')
     s.join('-')
"a-p-p-l-e"
let s = Array('a','p','p','l','e')
     s.join()
"a,p,p,l,e"
let s = Array('a','p','p','l','e')
     s.toString
ƒ toString() { [native code] }
let s = Array('a','p','p','l','e')
     s.toString()
"a,p,p,l,e"

js中的join()与split()函数的区别和用法_第1张图片

const str ="hello,word"
console.log( str.split(','));
console.log( str.split(''));
VM730:2 (2) ["hello", "word"]
VM730:3 (10) ["h", "e", "l", "l", "o", ",", "w", "o", "r", "d"]

js中的join()与split()函数的区别和用法_第2张图片

你可能感兴趣的:(java,servlet,服务器)