Skip to content

Commit

Permalink
🚿 map String.prototype.contains to String.include() (prototypejs#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Mar 2, 2021
1 parent cf0e825 commit aa2cec3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/prototype/lang/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ Object.extend(String.prototype, (function(){
* //-> false
**/
function include(pattern){
return this.indexOf(pattern) > -1;
return this.indexOf(pattern) !== -1;
}

/**
Expand Down Expand Up @@ -945,7 +945,8 @@ Object.extend(String.prototype, (function(){
unfilterJSON : unfilterJSON,
isJSON : isJSON,
evalJSON : evalJSON,
include : include,
//ECMA 6 supports contains(), if it exists map include() to contains()
include : String.prototype.contains || include,
// Firefox 18+ supports String.prototype.startsWith, String.prototype.endsWith
startsWith : String.prototype.startsWith || startsWith,
endsWith : String.prototype.endsWith || endsWith,
Expand Down

0 comments on commit aa2cec3

Please sign in to comment.