例如我有一个如下所示的数组:
hasNext()
并且我想使用[
"May 30, 2015 12:00:00 AM",
"Jun 6, 2015 12:00:00 AM",
"Jun 13, 2015 12:00:00 AM",
"Jun 20, 2015 12:00:00 AM"
]
将所有replace()
转换为12:00:00 AM
,以便它变为
empty
我怎么能这样做?
答案 0 :(得分:2)
使用for
迭代数组项并替换它们的内容。
var arr = [
"May 30, 2015 12:00:00 AM",
"Jun 6, 2015 12:00:00 AM",
"Jun 13, 2015 12:00:00 AM",
"Jun 20, 2015 12:00:00 AM"
];
for (var i = 0; i < arr.length; i++) {
arr[i] = arr[i].replace(" 12:00:00 AM", "");
}
console.log(arr);
&#13;