JavaScript 将字符串拆分为数组
例子
用于.split从字符串到拆分子字符串的数组:
var s = "one, two, three, four, five" s.split(", "); //["one", "two", "three", "four", "five"]
使用数组方法.join返回字符串:
s.split(", ").join("--"); // "one--two--three--four--five"
用于.split从字符串到拆分子字符串的数组:
var s = "one, two, three, four, five" s.split(", "); //["one", "two", "three", "four", "five"]
使用数组方法.join返回字符串:
s.split(", ").join("--"); // "one--two--three--four--five"