js原型链自定义添加功能方法

都是基础知识:直接上源码

    String.prototype.isString=function(num){
       console.log(this) // String {"hahahaha999"}
       return this.indexOf(num)>-1
     }
     var str="hahahaha999";
     console.log(str.isString(0)) // false
     console.log(str.isString(9)) //true

猜你喜欢

转载自www.cnblogs.com/linyuxuan/p/12112146.html