First, we need to instantiate the Queue class that we created. Next, we can verify that it is empty (the output is true because we have not added any elements to our queue yet):
const queue = new Queue();console.log(queue.isEmpty()); // outputs true
Next, let's add some elements to it (let's enqueue the elements 'John' and 'Jack'; you can add any element type to the queue):
queue.enqueue('John');queue.enqueue('Jack');console.log(queue.toString()); // John,Jack
Let's add another element:
queue.enqueue('Camila');
Let's also execute some other commands:
console.log(queue.toString()); // John,Jack,Camilaconsole.log(queue.size()); // outputs 3console.log(queue.isEmpty()); // outputs falsequeue.dequeue(); // remove Johnqueue.dequeue(); ...