Is JavaScript , ok ?

Well there certainly are mistakes in its design. And since it came to be, out of pure accident, or luck, it could be much worse, that’s for sure. By far the worse mistake being its name.

But… nothing is more expressive then short and sweet JavaScript. I defy any C# “afficionado” to show me parallel to this, in her favourite language ;o)
[sourcecode lang=”jscript”]
if ("function" !== typeof "".minus)
String.prototype.minus = function( what_ ) {
///<summary>
/// "ABCBDBEB".minus("B"), returns : "ACDE"
/// Argument is optional, by default it is one space char
/// myText.minus(), returns myText without spaces
/// argument can be an regular expression
/// reg.exp. given does not require ‘g’ or ‘m’ modifier
/// if argument is not found in the original, the original is returned
///</summary>
return (this.split(what_ || " " )).join( "" ) ;
}
[/sourcecode]
This little nugget, can be talked about on more “levels” than one. But, you will not be reading this if you would need this explained in a greater detail, would you?

–DBJ

3 thoughts on “Is JavaScript , ok ?”

Comments are closed.