String.prototype.contains:检查传递数组中的至少一个字符串是否包含在字符串中

时间:2021-05-30 20:49:00
【文件属性】:
文件名称:String.prototype.contains:检查传递数组中的至少一个字符串是否包含在字符串中
文件大小:1KB
文件格式:ZIP
更新时间:2021-05-30 20:49:00
JavaScript String.prototype.contains提案 问题 假设我想检查一个字符串是否包含多个字符串中的至少一个其他字符串: 在 ES5 var str = 'Hello this is a string' ; // Using regex: / Hello | is / . test ( str ) ; // true // 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.conta
【文件预览】:
String.prototype.contains-master
----README.md(2KB)
----contains.js(282B)

网友评论