This is straight from the console in IE (Microsoft Edge 25.10):
greg = new Date().toLocaleTimeString().split(':')[0];
"12"
greg = new Date().toLocaleTimeString().split(':')[0]=="12";
false
why?
This is straight from the console in IE (Microsoft Edge 25.10):
greg = new Date().toLocaleTimeString().split(':')[0];
"12"
greg = new Date().toLocaleTimeString().split(':')[0]=="12";
false
why?
It's because there are two invisible characters in the string: U-200E (left-to-right marks) at the beginning and end:
new Date().toLocaleTimeString().split(':')[0] == "\u200e12\u200e" // true
toLocaleTimeString
is defined here by ECMA-402 if the browser supports ECMA-402; otherwise, it's completely up to the implementation. IE doesn't support ECMA-402 and thus it can put anything in that string it likes. Including left-to-right marks seems a bizarre thing to do, but...
Strangely, there appear to be some invisible characters surrounding the numbers in that time string:
This can be circumvented / solved by parsing the split part as integer:
var part = new Date(2016, 00, 01, 10, 55, 30) // Fri Jan 01 2016 10:55:30
.toLocaleTimeString().split(':')[0];
console.log(part);
console.log(part == "10");
console.log(parseInt(part) == 10);