let str = "jkjsgfhiasdggaacvdsawe"; let res = str.substring(0,str.length-4); res+="****"; console.log(res) 运行结果: