Quantcast
Channel: Instanceof inconsistency - Stack Overflow
Browsing latest articles
Browse All 5 View Live

Answer by Halcyon for Instanceof inconsistency

I've done some digging and I suppose it has to do with string interning which is a compiler optimization.Okay, ready for some gotchas? :D"abc" == "abc"; // true"abc" === "abc"; // trueI suppose this is...

View Article



Answer by Ry- for Instanceof inconsistency

'' isn't an instance of anything; it's a primitive type, and it works in much the same way as 5.5 or true. There's a difference between a string primitive and a String object. See:new String('')...

View Article

Answer by user1106925 for Instanceof inconsistency

It's because '' is primitive, not an object.Some primitives in JavaScript can have an object wrapper. These are created when you make an instance of the wrapper using the built in constructor with...

View Article

Answer by Jon Newmuis for Instanceof inconsistency

Note the following:"" instanceof String; // => falsenew String("") instanceof String; // => trueinstanceof requires an object, but "" is a string literal, and not a String object. Note the...

View Article

Instanceof inconsistency

Could someone please explain the following?[] instanceof Array; // true'' instanceof String; // false

View Article

Browsing latest articles
Browse All 5 View Live




Latest Images