for my below code I want to setup a default toString() method which overrides the inbuilt toString() for this class. But its not working and I get the output "Queue { data: [] }" instead of expected "Hello This is example". I looked at some already discussed similar questions on SO but no help. I also tried on latest version of Chrome and behaviour is same. I have Node 10.13 with Babel 6 (babel-node --presets env,stage-2 queue.js). Looking for some expert opinion here.
class Queue {
constructor() {
this.data = [];
}
toString() {
console.log("Hello This is example");
}
}
const queue1 = new Queue();
console.log(queue1);