join 将数组拼接为字符串

  1. var arr = ["html","css","javascript"]
  2. console.log(arr.join()); // html,css,javascript
  3. console.log(arr.join("|")); // html|css|javascript
  4. console.log(arr.join("")); // htmlcssjavascript

split( ) 将字符串分割成字符串数组

  1. var str = "hello"
  2. console.log(str.split()); // 将字符串转为数组 ["hello"]
  3. console.log(str.split("")); // ["h","e","l","l","o"]
  4. console.log(str.split("e"));// ["h","llo"]