Content deleted Content added
Deltaspace42 (talk | contribs) m Reverted 1 edit by DogTraining01 (talk) to last revision by 2605:A601:A916:C500:A11E:457A:E651:30B1 |
Simonmysun (talk | contribs) →Examples: Add note of the JavaScript chaining code |
||
Line 47:
Another example in [[JavaScript]] uses the built-in methods of Array:
<syntaxhighlight lang=javascript>filter
somethings
.filter(x => x.count > 10)
Line 53:
.map(x => x.name)
</syntaxhighlight>
Note that in JavaScript <code>filter</code> and <code>map</code> return a new shallow copy of the preceding array but <code>sort</code> operates in place. To get a similar behavior, <code>toSorted</code> may be used. But in this particular case, <code>sort</code> operates on the new array returned from <code>filter</code> and therefore does not change the original array.
==See also==
|