[javascript/en] Re-add note about truthiness of wrapped primitives

Previous incarnations of this section had `Number(0)` instead of
`new Number(0)`, which actually returns `0` due to the absence of the
`new` keyword; this commit re-adds that section and better still, makes
it actually correct!
This commit is contained in:
Adam Brenecki 2015-10-28 13:48:53 +10:30
parent d4d471ef50
commit c3a66e60a6

View File

@ -507,6 +507,10 @@ myNumber === myNumberObj; // = false
if (0){
// This code won't execute, because 0 is falsy.
}
if (new Number(0)){
// This code will execute, because wrapped numbers are objects, and objects
// are always truthy.
}
// However, the wrapper objects and the regular builtins share a prototype, so
// you can actually add functionality to a string, for instance.