JavaScript parentheses converts primitive type to object

javascript

Solution

No, the parentheses are just letting the parser understand that the `.` is not a decimal point.

`12345 .toString()` will also work.

Primitive numbers implicitly converted to Numbers whenever you access their properties, but the objects are temporary and immediately lost. For example:

var foo = 5;

foo.bar = "something";

console.log(foo.bar); // undefined

Same goes for strings and booleans.

Problem

If numbers are primitive types, why I can do: ``` > (12345).toString() "12345" ``` Is the parenthesis converting the primitive type to a `Number`?

Original source

Related problems