4 ms·
Personally, this isn't bad - some kind of literal notation for date objects seems like a good idea (we already have octal and binary literals). The other optio
by pfooti 10y ago
Personally, this isn't bad - some kind of literal notation for date objects seems like a good idea (we already have octal and binary literals).
The other option ("#date#") is bad, IMO, since it's a magic string. I don't like magic strings because they blow up at unexpected times. Imagine the notice to the users: "please stop using the hashtag #racecar#, we know palindromes are cool, but it is causing our database to crash". I had similar issues with CDATA blocks in XML, actually - escaping strings to afford reasonable parsing is never fun.
- sopooneo 10y agoYour note about octal and binary literals sort of goes back and forth compared to the idea of date literals for me. Because octal and binary literals are supported in vanilla javascript, but are not explicitly supported in JSON. However, throwing them in seems like only a minor transgression since they are native to javascript, and are effectively just another representation of a number. On the other hand, the date literal you suggest is not part of javascript. And on that note, why not just use timestamps for dates in json?