D
Dr J R Stockton
Sun said:Dr J R Stockton wrote on 28 okt 2006 in comp.lang.javascript:
function isLeapyear(yr) {
return new Date(yr,1,29).getMonth()==1
}
function isLeapyear(yr) { return new Date(yr, 2, -28).getMonth() }
returns 0 or 1, which can be used directly in a context demanding
Boolean, can be converted to true Boolean with ! or !!, and can be used
to index an array. No comparison operation required. Speed is about
doubled (for me) by using UTC.