-
Notifications
You must be signed in to change notification settings - Fork 22.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference for stage 3 set-methods #28414
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add links to core-js
polyfills of those methods -)
Sorry, I thought I did 😄 |
Is someone taking on the compatibility data for this? I can do it if needed, but not going to to so if already in hand. |
Already here: mdn/browser-compat-data#20479 |
files/en-us/web/javascript/reference/global_objects/set/difference/index.md
Show resolved
Hide resolved
a9b6a01
to
b71e70f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
partial review.
|
||
In mathematical notation, _difference_ is defined as: | ||
|
||
<math display="block"><semantics><mrow><mi>A</mi><mo>∖</mo><mi>B</mi><mo>=</mo><mo stretchy="false">{</mo><mi>x</mi><mo>∊</mo><mi>A</mi><mo>∣</mo><mi>x</mi><mo>∉</mo><mi>B</mi><mo stretchy="false">}</mo></mrow><annotation encoding="TeX">A\setminus B = \{x\in A\mid x\notin B\}</annotation></semantics></math> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The <mo>∊</mo>
and <mo>∉</mo>
are very different sizes. Just want to confirm that that is OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's mostly a font issue. MDN doesn't seem to be using a decent math font.
files/en-us/web/javascript/reference/global_objects/set/difference/index.md
Outdated
Show resolved
Hide resolved
|
||
`difference()` accepts [set-like](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#set-like_objects) objects as the `other` parameter. It requires {{jsxref("Operators/this", "this")}} to be an actual {{jsxref("Set")}} instance, because it directly retrieves the underlying data stored in `this` without invoking any user code. Then, its behavior depends on the sizes of `this` and `other`: | ||
|
||
- If there are more elements in `this` than `other.size`, then it iterates over `other` by calling its `keys()` method, and constructs a new set with all elements in `this` that are not seen in `other`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If there are more elements in `this` than `other.size`, then it iterates over `other` by calling its `keys()` method, and constructs a new set with all elements in `this` that are not seen in `other`. | |
- If there are more elements in `this` than `other.size`, then it iterates over `other` by calling its {{jsxref("Set.prototype.keys()", "keys()")}} method, and constructs a new set with all elements in `this` that are not seen in `other`. |
or /en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The keys()
method here is an arbitrary method that the user provides, which may or may not be Set.prototype.keys()
. This is explained in the "set-like objects" section, linked above.
files/en-us/web/javascript/reference/global_objects/set/difference/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/set/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/set/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/set/index.md
Outdated
Show resolved
Hide resolved
@@ -88,14 +165,28 @@ These properties are defined on `Set.prototype` and shared by all `Set` instance | |||
- : Removes all elements from the `Set` object. | |||
- {{jsxref("Set.prototype.delete()")}} | |||
- : Removes the element associated to the `value` and returns a boolean asserting whether an element was successfully removed or not. `Set.prototype.has(value)` will return `false` afterwards. | |||
- {{jsxref("Set.prototype.difference()")}} | |||
- : Takes a set and returns a new set containing elements in this set but not in the given set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- : Takes a set and returns a new set containing elements in this set but not in the given set. | |
- : Takes a set and returns a new set containing elements in this set that are not in the given set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find both equally fine, but the preposition "but" makes the logical relationship slightly more saliant.
files/en-us/web/javascript/reference/global_objects/set/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/set/intersection/index.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally missed this. Sorry. This wasn't in my notifications.
Description
Adds reference for https://github.com/tc39/proposal-set-methods.
See also mdn/browser-compat-data#20479 for which browsers support it (currently Safari TP and FF nightly).
Motivation
Additional details
Related issues and pull requests