Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
ricardobeat
on Jan 27, 2013
|
parent
|
context
|
favorite
| on:
Stupid Languages
Object('abc') is the same as new String('abc'), Object(1) the same as new Number(1) - it just calls the .constructor
iso-8859-1
on Jan 27, 2013
[–]
but "new Number(x)" is not equal to "Number(x)". So, it's tricky, I guess?
ville
on Jan 27, 2013
|
parent
[–]
Number(x) performs a type conversion to number, new Number(x) constructs a primitive wrapper object Number:
typeof Number("10") //=> "number" typeof new Number("10") //=> "object"
The same applies to other wrapper objects, that is, Boolean and String.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: