This post is about a couple of probably useful JavaScript functions, that on daily basis could make our code smarter ;) String.prototype.Replace Ok, ok, a prototype into a native constructor is not a good start point, but this one, strings dedicated, is probably one of those "must have" protos, a Replace with multiple inputs, as is for PHP. String.prototype.Replace = function(replace){return function(RegExp, String){ if(!(RegExp instanceof Array)) RegExp = [RegExp]; if(!(String instanceof Array)) String = [String]; for(var result = this, i = 0, l = 0, index = RegExp.length, length = String.length; i result = replace.call(result, RegExp[i], String[l return result; }}(String.prototype.replace); With above prototype it is possible to search and replace with multiple RegExps and multiple replacements. The proto works as native replace one, but it is possible to perform a replace like this as well: "abc".Replace([/a/, /b/, /c/], ...