endWith is not a function

解决方法,增加String的扩展

String.prototype.endWith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};

使用:

"test".endWith("$")

 

参考:

https://stackoverflow.com/questions/18768344/javascript-endswith-function-not-working

https://stackoverflow.com/questions/280634/endswith-in-javascript

posted @ 2017-09-26 11:07  EasonJim  阅读(573)  评论(0编辑  收藏  举报