One of the "neat" things in Javascript is you are able to dynamically add or change methods of a class and automatically update every instance of that class. Some of the things I usually find useful are adding to the String class, like so:
String.prototype.htmlSpecialChars = function() {
return this.replace(/\</g,'<').replace(/\>/g,'>');
}
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
}
Obviously we cannot do this in PHP, and why would we, right? However we can emulate this behaviour to a certain extent using my "neat" little Prototype class. With this Prototype class we can dynamically add properties and methods to any class, and they will be inherited by all instances of that class.