Reputation: 12531
Using a JavaScript Set, is it possible to modify a value previously added?
For example:
const mySet = new Set()
mySet.add(42)
mySet.set(0, 69)
.set
is made up, I just want to modify the set at index 0. Is there any way to do this or should I be using a regular array or even a Map?
Upvotes: 0
Views: 472
Reputation: 7120
No, you have to remove it and readd the appropriate value. Sets only contain values, nothing more.
Sets don't have an index. You can use a Map or object, as you suggested.
Upvotes: 1