I noticed the following differences in return values when comparing strings containing "-1", "1"and "0"using String.prototype.localeCompare()in Chrome and Edge:
"1".localeCompare("-1");
"0".localeCompare("-1")
"-1".localeCompare("1")
- Why is there a difference in return values between browsers?
- Is there a way for browsers to consistently follow in the scripts above?
source
share