-
Notifications
You must be signed in to change notification settings - Fork 23k
Fix array some grammar #42148
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
Fix array some grammar #42148
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,7 @@ browser-compat: javascript.builtins.Array.indexOf | |
| sidebar: jsref | ||
| --- | ||
|
|
||
| The **`indexOf()`** method of {{jsxref("Array")}} instances returns the first index at which a | ||
| given element can be found in the array, or -1 if it is not present. | ||
| The **`indexOf()`** method of {{jsxref("Array")}} instances returns the first index at which an element can be found in the array, or -1 if it is not present. | ||
|
|
||
| {{InteractiveExample("JavaScript Demo: Array.prototype.indexOf()")}} | ||
|
|
||
|
|
@@ -36,10 +35,10 @@ indexOf(searchElement, fromIndex) | |
| ### Parameters | ||
|
|
||
| - `searchElement` | ||
| - : Element to locate in the array. | ||
| - : The element to locate in the array. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None of the other parameter descriptions start with "The" or "A" either, and I think it's fine either way. |
||
| - `fromIndex` {{optional_inline}} | ||
| - : Zero-based index at which to start searching, [converted to an integer](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#integer_conversion). | ||
| - Negative index counts back from the end of the array — if `-array.length <= fromIndex < 0`, `fromIndex + array.length` is used. Note, the array is still searched from front to back in this case. | ||
| - Negative index counts back from the end of the array — if `-array.length <= fromIndex < 0`, `fromIndex + array.length` is used. Note: the array is still searched from front to back in this case. | ||
| - If `fromIndex < -array.length` or `fromIndex` is omitted, `0` is used, causing the entire array to be searched. | ||
| - If `fromIndex >= array.length`, the array is not searched and `-1` is returned. | ||
|
|
||
|
|
@@ -49,7 +48,7 @@ The first index of `searchElement` in the array; `-1` if not found. | |
|
|
||
| ## Description | ||
|
|
||
| The `indexOf()` method compares `searchElement` to elements of the array using [strict equality](/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality) (the same algorithm used by the `===` operator). [`NaN`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) values are never compared as equal, so `indexOf()` always returns `-1` when `searchElement` is `NaN`. | ||
| The `indexOf()` method compares `searchElement` to elements of the array using [strict equality](/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality) (the same algorithm used by the `===` operator). [`NaN`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) values are never considered equal, so `indexOf()` always returns `-1` when `searchElement` is `NaN`. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is an improvement |
||
|
|
||
| The `indexOf()` method skips empty slots in [sparse arrays](/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays). | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,7 +53,7 @@ The `some()` method is an [iterative method](/en-US/docs/Web/JavaScript/Referenc | |
|
|
||
| `callbackFn` is invoked only for array indexes which have assigned values. It is not invoked for empty slots in [sparse arrays](/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays). | ||
|
|
||
| `some()` does not mutate the array on which it is called, but the function provided as `callbackFn` can. Note, however, that the length of the array is saved _before_ the first invocation of `callbackFn`. Therefore: | ||
| `some()` does not mutate the array on which it is called, but the function provided as `callbackFn` can. However, note that the length of the array is saved _before_ the first invocation of `callbackFn`. Therefore: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is an improvement in any way. We have may such cases if you search "Note, however,". |
||
|
|
||
| - `callbackFn` will not visit any elements added beyond the array's initial length when the call to `some()` began. | ||
| - Changes to already-visited indexes do not cause `callbackFn` to be invoked on them again. | ||
|
|
||
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.
Plural is correct: https://english.stackexchange.com/questions/197798/singular-or-plural-verb-after-no