On ECMAScript, it explains how you would create the add prototype.
The following steps are taken:
Let S be the this value.
If Type(S) is not Object, throw a TypeError exception.
If S does not have a [[SetData]] internal slot, throw a TypeError exception.
Let entries be the List that is the value of S’s [[SetData]] internal slot.
Repeat for each e that is an element of entries,
If e is not empty and SameValueZero(e, value) is true, then
Return S.
If value is −0, let value be +0.
Append value as the last element of entries.
Return S."
I am fairly new to JS and have no idea what this means. If I were to create a class such that
class mySet {
constructor(){
this.set = {}
}
//adds a value to set
add(){
}
How would I proceed?