SOURCE

~function(){
    function myIndexOf(s){
        let reg = new RegExp(s);
        console.log(this)
        let res = reg.exec(this);
        if(res == null){
            return -1
        }else{
            return res.index;
        }        
    }
    String.prototype.myIndexOf = myIndexOf;
}()

let str = 'nishibushiyigeren';
console.log(str.myIndexOf('bus'))
console 命令行工具 X clear

                    
>
console