As I delve deeper into JavaScript, I stumbled upon an interesting quirk in its behavior.
When creating date objects like this:
var stack = new Date(1404187200000) // 07-01-2014
var overflow = new Date('07-01-2014')
I noticed that when comparing these two date objects:
stack == overflow // returns false
stack.getTime() == overflow.getTime() // returns true
I speculated that this discrepancy is due to them not being the same object. However, I am aware that '==' checks for equality while '===' compares identity, as shown in this example:
var stack = 1;
var overflow = '1';
stack == overflow // returns true
stack === overflow // returns false
So why then, does comparing new Date([NUMBER]) and new Date([STRING]) yield different results even though they represent the same date?
Your insights on this matter would be greatly appreciated!