String prototypes in JavaScript
Shows how to create a String prototypes
String.prototype.stripslashes = function(){
return this.replace(/<.*?>/g, '');
};
String.prototype.htmlspecialchars = function(){
var str = this.replace(/&/g, '&');
str = str.replace(/</g, '<');
str = str.replace(/>/g, '>');
str = str.replace(/"/g, '"');
return str;
};
Url: http://www.jonasjohn.de/snippets/javascript/string-prototypes.htm
Language: JavaScript | User: ShareMySnippets | Created: Jan 12, 2014 | Tags: javascript htmlspecialchars string prototype