This is the specification for a proposed Array.prototype.reject
method in JavaScript.
It is modified from Array.prototype.filter
in ECMAScript specification.
This method works like Array.prototype.filter
but has opposite result.
predictor should be a function that accepts three arguments and returns a value that is coercible to a Boolean value.
reject
calls predictor once for each element in the array, in ascending order,
and constructs a new array of all the values for which predictor returns
If a thisArg parameter is provided, it will be used as the
predictor is called with three arguments: the value of the element, the index of the element, and the object being traversed.
reject
does not directly mutate the object on which it is called but the object
The range of elements processed by reject
is set before the first call to predictor.
Elements which are appended to the array after the call to reject
begins will not be visited by predictor.
If existing elements of the array are changed their value as passed to predictor will be the value at the time reject
visits them;
elements that are deleted after the call to reject
begins and before being visited are not visited.
When the reject
method is called, the following steps are taken:
The reject
function is intentionally generic; it does not require that its
This specification is authored on GitHub in a plaintext source format called Ecmarkup.
Ecmarkup is an HTML and Markdown dialect that provides a framework and toolset for authoring ECMAScript specifications in plaintext and processing the specification into a full-featured HTML rendering that follows the editorial conventions for this document. Ecmarkup builds on and integrates a number of other formats and technologies including Grammarkdown for defining syntax and Ecmarkdown for authoring algorithm steps.
© 2021 Tzu-Te Kuo (Davy) <me@davy.tw>
Original ECMAScript specification, copyright © 2021 Ecma International
MIT License Copyright (c) 2021 Tzu-Te Kuo (Davy) <me@davy.tw> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.