If numbers are primitive types, why I can do:
> (12345).toString()
"12345"
Is the parenthesis converting the primitive type to a Number?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
Same goes for strings and booleans.