According to MDN ,
By default, the
toString()method is inherited by every object descended fromObject. If this method is not overridden in a custom object,toString()returns "[object type]", wheretypeis the object type.
Consider the following example
const toString = Object.prototype.toString;
toString.call(new Date); // [object Date]
toString.call(new String); // [object String]
toString.call(Math); // [object Math]
I don’t understand why toString.call(new String) returns [object String]
From the MDN, it should return [object type] where type should be object in this case
because console.log (new String) print out {" " } , it is an object
the same goes for new Date, it also displaced “object” after typing typeof new Date