Javascript…
Javascript is both infuriating and awesome at the same time. I don’t think I’ve ever speant so much time tracking down annoying bugs (even compared to PHP), yet at the same time it makes functions like the one below very simple to write.
For reference, the below code returns a `getter` method that we use to instantiate objects via a cache system.
var buildSimpleObjectGetter = function(cacheRef, objectRef)
{
var f = "buildSimpleObjectGetter()";
UTILS.checkArgs(f, arguments, [ObjectCache, Function]);
return function(idRecord, idArg)
{
return cacheRef.get('' + idArg, function()
{
return new objectRef(idRecord, idArg);
});
}
}
Update 20080327:
On the topic of stupid Javascript bugs, who thought auto terminating lines was a good default!
function getWords()
{
return
[
'Hello',
'World!'
];
}
console.info(getWords());
// Ouput
// >>> undefined