Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

new String("foo") === new String("foo") is false. === does not mean value and type are equal, it means that the left is the same object as on the right OR that both the left and right are primitives with the same value.


The behavior there is a result of the 'new' operator. typeof new String("foo") is specified to be "object", and it is extensible (String("foo") is not). Both == and === on two object-types return true if both refer to the same thing. More generally, when two types are the same, == has the same behavior as ===.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: