according to MDN when using the unary plus operator:
Integers in decimal and hexadecimal formats ("0x" -converted) are supported. Negative numbers are supported ( but not for hex ). If it cannot analyze a specific value, it will be evaluated to NaN.
But when I run this Jasmine test (a match toBe()
applies the ===
operator):
it("should return NaN when trying to convert a string representing a NEGATIVE HEX to the corresponding number", function() { var a = '-0xFF'; expect(typeof +a).toBe('number'); expect(isNaN(+a)).toBeTruthy();
It does not work in Chrome and Opera (and goes through IE, Safari and Firefox).
Is this a flaw in Chrome and Opera devices, or am I missing something?
source share