JavaScript Object.prototype.toString() Method
The toString() method returns a string representing an object. The default for plain objects is "[object Object]", but many types override it.
Description
The toString() method returns a string representation of an object. JavaScript calls it automatically when an object is converted to a string, such as in concatenation. Plain objects return "[object Object]", which is rarely useful; arrays, dates, numbers, functions and errors provide their own versions.
Calling Object.prototype.toString.call(value) gives a reliable type tag like "[object Date]". To display an object's contents, use JSON.stringify().
Classes can customize the tag reported by Object.prototype.toString() by defining a Symbol.toStringTag getter, which is how built-ins such as Map report "[object Map]". For logging, browsers' consoles show objects interactively, so console.log(obj) is usually more useful than converting it to a string.
Syntax
obj.toString()Return Value
A string representing the object, by default "[object Type]".
Example
Browser Support
The following information will show you the current browser support for the Object.prototype.toString() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





