remove first item in set javascript code example
Example 1: js remove first item
let myArray = [1, 2, 3, 4, 5];
let removedElement = myArray.shift();
Example 2: remove from set javascript
// Create new set
const animals = new Set();
// Add to set
animals.add('cat');
animals.add('dog');
// Remove from set
animals.delete('cat'); // returns true
animals.delete('dog'); // returns true
animals.delete('horse'); // returns false