Typed Wrappers
JavaScript has a set of typed wrappers. For example:
new Boolean(false)
produces an object that has a valueOf
method
that returns the wrapped value. This turns out to be completely unnecessary and
occasionally confusing. Don't use new Boolean
or
new Number
or new
String
.
Also avoid new Object
and new Array
. Use {}
and []
instead.
Get JavaScript: The Good Parts now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.