在指定位置截取字符串并在当中插入字符串数据

// 在指定位置截取字符串并在当中插入字符串数据
function newStr(str, n,tr) {
    var newStr = str.slice(0, n) + tr + str.slice(-str.length + n)
    return newStr
}
console.log(newStr('12111111115', 3,'---')) // 121111111.15

 

posted @ 2021-09-10 16:48  iHadThreeDreams  阅读(93)  评论(0)    收藏  举报