Timing for optimization purposes:

Code:
Function.prototype.time =
  function() {
    var sTime = new Date();
    this.apply(null,arguments);
    var eTime = new Date();
    return eTime.getTime() - sTime.getTime();
  };
Say you have a function f. To time the function with arguments arg0, arg1 & arg2 do

Code:
f.time(arg0,arg1,arg2);