I have a class:
class Test{
contructor(){
this.x = "test"
}
}
var t = new Test()
var toString = Object.prototype.toString
console.log(toString.call(t))
the log prints [object Object]
, i would like it to print something like [object Test]
, how can i do that? I tried doing
Test.prototype.toString = function() {
return "[object Test]"
}
but that didn't work, any help?