The objToString() method returns a string representing the object. This explicitly always calls the Object.prototype.toString() method.
objToString()
Object.prototype.toString()
An object's toString() method is most commonly invoked when that object undergoes:
The object to be converted into a string
A string representation of the object
objToString(new Date()); // [object Date]objToString(new String()); // [object String]// Math has its Symbol.toStringTagobjToString(Math); // [object Math]objToString(undefined); // [object Undefined]objToString(null); // [object Null] Copy
objToString(new Date()); // [object Date]objToString(new String()); // [object String]// Math has its Symbol.toStringTagobjToString(Math); // [object Math]objToString(undefined); // [object Undefined]objToString(null); // [object Null]
The
objToString()
method returns a string representing the object. This explicitly always calls theObject.prototype.toString()
method.An object's toString() method is most commonly invoked when that object undergoes: