1 year ago
#364984
Sibashrit Pattnaik
in JavaScript toString method doesn't directly run an empty object, instead runs on a variable which is assigned to an empty object
I tried this today on my browser console and saw something weird. Please help. Can someone help me understand why It happens ?
Try 1:
{}.toString(); // It shows an error - Uncaught SyntaxError: Unexpected token '.'
Try 2:
const a = {};
a.toString(); // It returns '[object Object]'
javascript
node.js
ecmascript-6
tostring
0 Answers
Your Answer