Namespaced Methods in JavaScript
Once upon a time I was asked (well, actually a question wasn't for me only, but for whole habrahabr's community) is it possible to implement namespaced methods in JavaScript for built-in types like:
5..rubish.times(function() { // this function will be called 5 times
console.log("Hi there!");
});
"some string".hask.map(function(c) { return c.hask.code(); });
// equivalent to
"some string".split('').map(function(c) { return c.charCodeAt(); });
"another string".algo.lcp("annotation");
// returns longest common prefix of two strings
As you can see at the link, it's possible using ECMAScript 5 features. And that's how: