The split method is used to cut a string into an array of strings, as opposed to a join
A parameter indicates that the parameter is a cutting point,
1 varStr= "Silence ' s World";2Console.log (Str.split (""));//["Silence S", "World"]3Console.log (Str.split ("'"));//["Silence", "s World"]4Console.log (Str.split (""));//["s", "I", "L", "E", "N", "C", "E", "'", "s", "", "w", "O", "R", "L", "D"]5 //two parameters, the latter parameter indicates the length of the6Console.log (Str.split ("'", 1));//["Silence"]7Console.log (Str.split ("", 5));//["s", "I", "L", "E", "N"]
The Join method is used to concatenate the array into a string
1 var arr=["s", "I", "L", "E", "N", "C", "E"]2 console.log (Arr.join (",")); s,i,l,e,n,c,e3 console.log (Arr.join ("")); Silence4 console.log (Arr.join (".")); // S.I.L.E.N.C.E 5 Console.log (Arr.join ("|")); // s|i|l|e|n|c|e
JS string function split () join ()