Why does comparing an explicitly called String
constructor to an implicit string evaluate true
, but adding the new
keyword makes it evaluate false
on deep equals, but true
again on shallow equals?
> "hello"===String("hello")
true
> "hello"==new String("hello")
true
> "hello"===new String("hello")
false
Edit: after further testing, this appears to happen with all types that have implicit constructors.
Edit 2: to clarify, this is not a question of ==
vs. ===
, but one of implicit vs. explicit constructors.