1. split //可以将字符串分割为数组

1.split 可以分割字符串为数组,也可为几段字符串

  1. <script>
  2. /* split 可以将字符串分割为数组 */
  3. var str = "hello wo";
  4. 1. var arr = str.split("");
  5. console.log(arr); // Array(7) h,e,l,l,o,w,o
  6. 2. var arr=str.split(" ")
  7. console.log(arr) // (2) ["jello", "world"]
  8. 3. var arr=str.split("e")
  9. console.log(arr) // (2) ["j", "llo world"]
  10. </script>

2.