remove redundance in compare-functions
No need to check if the variables are instanceof Date. A dates value is its time so when you make (less than/greater than) comparisons with a Date instance (x) you're essentially comparing it to +x or x.valueOf() which will be the same as x.getTime(). Therefore the below will always be equivalent:

function equal(a, b) {
    if (a instanceof Date &amp;&amp; b instanceof Date) return +a == +b; //compare the 2 dates times as noted in the above statement +x == x.getTime() == x.valueOf()
    return a == b;
}

function lessThan(a, b) {
    return a &lt; b;
}

function greaterThan(a, b) {
    return a &gt; b;
}