js对数组的一些处理?
var list = [
{time: '2022/08/18 14:37:15'},
{time: '2022/08/18 14:37:15'},
{time: '2022/08/18 14:37:15'},
{time: '2022/08/18 14:37:15'},
{time: '2022/08/18 14:37:15'}
]
以上数组处理得到:list = [
{time: '2022-08-18 14:37:15'},
{time: '2022-08-18 14:37:15'},
{time: '2022-08-18 14:37:15'},
{time: '2022-08-18 14:37:15'},
{time: '2022-08-18 14:37:15'}
]
回答:
日期中间的斜杠/
改成中横线-
吗?
list.map(item => { return {
...item,
time: item.time.replace(/\//g, '-'),
}
})
回答:
const newList = list.map(x => { return {
time: x.time.replace(/\//g, '-')
}
})
回答:
const data = JSON.parse(JSON.stringify(list).replace(/\//g,"-"));
以上是 js对数组的一些处理? 的全部内容, 来源链接: utcz.com/p/932844.html