Object Conversions
Can anyone pls explain in brief what are the important and necessary object to primitive conversions in brief. or object conversions with egs
10 Replies
what do you mean?
Thanks for responding.
Object to primitive type conversions.
GeeksforGeeks
How to convert an object to string using JavaScript ? - GeeksforGeeks
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
usually, you do it because you need it
there's 3 ways to do it:
-
toString
- toValue
- Symbol.toPrimitive
when do we come across these?
the example that immediately comes to mind is when we are retrieving and sending data between browser storage and our application. JSON.parse() and JSON.stringify()
yea true.
and these?
you almost never will use these
this is a reasonable usage of those, but, even then, it's super specific
yup.
so no need to worry about these.
you should know they exist, but don't worry an awful lot about those