Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Robert Merrill
6,215 PointsJavaScript primitive data types
I'm working on this question about what is true about JavaScript Primitive data types. Would love for someone to point out any links/defs that highlight which of these are true:
Which of the following are true about JavaScript primitive data types? A. Primitive types behave like objects when you use the property access notations B. Primitive data types can be assigned new properties C. New values can be assigned and accessed to the existing properties of primitive data types D. Primitive data types get wrapped with an object temporarily
1 Answer
Gunhoo Yoon
5,027 PointsA. Primitive value itself doesn't have method or property although it can use method and property prototypes. So I guess this is false.
B. Assigning new property to primitive type is only possible through prototype and this is not assigning property to primitive type. So I guess this is false
C. Pretty much same logic as B so I guess this is false.
D. JavaScript is loosely typed language so it probably should go through some process of identification and turn it into actual value. So I guess this is true.
Robert Merrill
6,215 PointsRobert Merrill
6,215 PointsThanks for the help. That brings some clarification. However, the assignment I'm working on seems to suggest that there are multiple choices that are correct. I wonder if either A or B could be true as well?
Gunhoo Yoon
5,027 PointsGunhoo Yoon
5,027 PointsWell A could be true depends on how you see it. For example, every string has length property which you can access. But I don't see how B and C can be true. For example, primitive types cannot be mutated. So I would probably answer A and D at most.