String.prototype.containsAll:检查传递数组中的所有字符串是否都包含在字符串中

时间:2021-05-30 18:58:09
【文件属性】:
文件名称:String.prototype.containsAll:检查传递数组中的所有字符串是否都包含在字符串中
文件大小:1KB
文件格式:ZIP
更新时间:2021-05-30 18:58:09
JavaScript String.prototype.containsAll提案 问题 假设我想检查一个字符串是否包含一堆字符串: 在 ES5 var str = 'Hello this is a string' ; // Using good old indexOf str . indexOf ( 'Hello' ) > - 1 && str . indexOf ( 'is' ) ; // true // Using ES6 (String.prototype.includes) str . includes ( 'Hello' ) && str . includes ( 'is' ) ; // true 那么如果我想用一堆字符串来做这件事会发生什么,这将是乏味和冗长的, String.prototype.containsAll来拯救: 解决方案 var str = 'Hello this is
【文件预览】:
String.prototype.containsAll-master
----containsAll.js(286B)
----README.md(2KB)

网友评论