Javascript Date sadness

There are many things to dislike about the Javascript Date library, but this one keeps tripping me up so I better write it down:


typeof(new Date(1341070612432))

The confusing thing is that Date is both a Javascript class that returns Date objects and a convenience function that returns strings. Most of my Javascript programming is in D3’s style which never uses constructors or the “new” keyword; instead its “classes” are functions that return objects. But a lot of core Javascript isn’t like that. Neither is Leaflet; I keep forgetting to say “new” there too.