title: How do I change the value of an item in a Set?
body: <p>I have a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set" rel="nofollow noreferrer">Set</a> that I want to update in JavaScript, but I can't figure out anything that lets me update values within it.</p>
  
  <pre><code>const mySet = new Set([]);
  mySet.add('hello');
  mySet.add('hewwo');
  mySet.add('henlo');
  </code></pre>
  
  <p>I've tried syntax like</p>
  
  <p><code>mySet['hello'] = 'hello world'</code>,</p>
  
  <p><code>mySet.hello = 'hello world'</code>, and </p>
  
  <p><code>mySet[0] = 'hello world'</code>. </p>
  
  <p>I've also tried modifying the value like this:</p>
  
  <pre><code>mySet.forEach(item =&gt; {
    if (item === 'hello') {
      item = 'hello world';
    }
  })
  </code></pre>
  
  <p>Nothing has worked for me so far though. I wanted to use a set over a normal array because it prevents duplicate items automatically, but should I just add the logic myself? Is there a good use case for sets in <code>JavaScript</code> if I can't modify the values in them?</p>