function insertStr(soure, firstPosition, firstStr, secondPosition, secondStr) {
soure = soure.slice(0, firstPosition) + firstStr + soure.slice(firstPosition)
return soure.slice(0, secondPosition) + secondStr + soure.slice(secondPosition)
}
let currentTime = 20210107
consolog(insertStr(currentTime, 4, '-', 7, '-'))
// 输出
2021-01-07
JS 字符串指定位置插入值
猜你喜欢
转载自blog.csdn.net/weixin_40639095/article/details/112319427
今日推荐
周排行