// 在index为1的位置替换成  哈哈哈  
        let str = "012345";
        let index = 1;
        str = str.substr(0, index) + " 哈哈哈 "+ str.substr(index+1);
        console.log(str);
        // 在index为1的位置插入  哈哈哈  
        let str2 = "012345";
        str2 = str2.substr(0, index) + " 哈哈哈 "+ str2.substr(index);
        console.log(str2);

字符串指定索引插入和替换文本

 

 

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-02-15
  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
相关资源
相似解决方案