I'm trying to convert string to object with the below code:
wishlisted= [ '626601b89f1c16d0e42fd58e' ]
console.log(wishlisted.map(id => ({ id })));
Output for this came as:
[ { id: '626601b89f1c16d0e42fd58e' } ]
But from the output, I think id
is of String
type. I want to return it just like MongoDB's id, like: 626601b89f1c16d0e42fd58e
, not as a string.
When I tried to check the type of id
using:
console.log(typeof wishlisted[0].id);
it came as undefined
.
What could be the best way to do this type casting?