You can use the augmentation type, especially if you need to use this function often:
String.prototype.isMatch = function(s){ return this.match(s)!==null }
So you can use:
var myBool = "ali".isMatch("Ali");
The general view is that the use of a type extension is not recommended just because it may interfere with other add-ons.
According to Javascript Patterns , its use should be limited.
I personally think that everything is fine if you use a good name, for example:
String.prototype.mycompany_isMatch = function(s){ return this.match(s)!==null }
This will make it ugly but safe .
source share