2

Possible Duplicate:
Why does instanceof return false for some literals?

Does anyone know why x is not a instance of String/Object here?

var x = "abc",
y = new String("XYZ");

x instanceof String; // False
x instanceof Object; // False
y instanceof String; // True
(x.constructor === y.constructor) //True

http://jsfiddle.net/pCfWC/6/

Community
  • 1
  • 1
sbr
  • 4,735
  • 5
  • 43
  • 49

0 Answers0