How to change the “[object Object]” label, returned by “Object.prototype.toString”, for my custom class?
13:36 09 Dec 2019

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?

javascript class prototype tostring