instanceof doesn't work correctly on literals

Oct 16, 2013 at 10:50 AM
Edited Oct 16, 2013 at 10:50 AM
"foo" instanceof String

is actually false according to the standard, however Jint thinks it's true. It should only be true if you use

new String("foo") instanceof String

Likewise, 42 instanceof Number should be false but Jint thinks otherwise.

Haven't quite figured out exactly what should be modified here, but note that Object.getPrototypeOf("foo") generates an error in all major browsers, indicating they somehow distinguish between a string literal and a string object (even though .constructor can be used on both!)