//const { Script } = require("node:vm");
//改写 检测某些特定字符并返回特定字符的索引
String.prototype.filter=function(){
if(arguments.length<1) throw new Error('缺少参数');
var a = [], _this = this;
for( var i =0; i < arguments.length; i++){
a.push(arguments[i]);
}
var i = -1;
var b=[];
a.forEach(function(key,m,n){
//var b=[];
i = _this.indexOf(key) //检索字符串在字符串中首次出现的位置,第二个参数表示开始检索的位置。方法.若没有检索到。则返回-1.
//console.log(i);
if(i == -1) i=false;
b.push(i);
//console.log(b);
});
return b;
}
var Str="hello world";
var result=Str.filter('e','z','d');
console.log(result);