Possible duplicate:
Why does instanceof return false for some literals?
If I...
[] instanceof Array;
... it returns true, although I have not used new Array().
But if I ...
"" instanceof String;
... it returns falsebecause I have not used new String().
Why? I understand that []- this is a language construct for creating arrays, and ""- this is a language construct for creating strings. Therefore, I do not understand why one returns trueand the other returns false.
In addition, all of the following codes return true:
[] instanceof Array;
Array() instanceof Array;
new Array() instanceof Array;
But with the lines:
"" instanceof String;
String() instanceof String;
new String() instanceof String;
Is it worth it to String() instanceof Stringreturn true?
Edit:
( ): , ?