SOURCE

String.prototype.count = function (str) {  
  let count = 0;
  for (var i = 0; i < this.length; i++) {
    if(this.charAt(i) == str){
      count ++;
    }
  }
  return count;
}
let str = '1212数据恢复看啥的份上都是数据';
console.log(str.count('数'));
console 命令行工具 X clear

                    
>
console