diff options
author | Adam Brenecki <adam@brenecki.id.au> | 2015-10-28 13:48:53 +1030 |
---|---|---|
committer | Adam Brenecki <adam@brenecki.id.au> | 2015-10-28 13:48:53 +1030 |
commit | c3a66e60a61de0b98ea3e86568dfddf76eae1069 (patch) | |
tree | 59d302f9482ae3a2fb98c49ddb0be2609540d409 /javascript.html.markdown | |
parent | d4d471ef50fb2e84dc8f1656a7037795bd44a89a (diff) |
[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!
Diffstat (limited to 'javascript.html.markdown')
-rw-r--r-- | javascript.html.markdown | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/javascript.html.markdown b/javascript.html.markdown index b5c3a3c8..cd75b0d2 100644 --- a/javascript.html.markdown +++ b/javascript.html.markdown @@ -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. |