Posting a bit of Javascript got me remembering about a cool feature in Javascript not every (web)developer is aware of (but should be...).
The prototype keyword lets you add methods and properties to custom objects, even some predefined objects like the string object!
function AddQuotes()
{
return('Quote: “' + this + '“');
}
String.prototype.Quoted = AddQuotes;
Now, every string in your Javascript has a Quoted() method...
function Bericht()
{
var msg = 'this sentence is not mine but a quote.';
alert(msg.Quoted());
}
Lousy example, but imagine what you can do with these possibilities...
I used this in a large webapplication to add things like Trim(), LTrim() en RTrim() to the string object.
Cool, right?
(I know, I know...
Not cutting edge .NET technology. Just thought I 'dump' it on the blog in case someone might find it usefull.)