Also, most generic Array methods are specialized to array-like objects, not iterables. My proposed semantics go along with this.
----- Isiah Meadows [email protected] Looking for web consulting? Or a new website? Send me an email and we can get started. www.isiahmeadows.com On Fri, Nov 10, 2017 at 7:09 AM, T.J. Crowder <[email protected]> wrote: > On Fri, Nov 10, 2017 at 11:41 AM, Bob Myers <[email protected]> wrote: >> >> What's wrong with this? > > I had the impression he was trying to avoid callbacks, just using `===`. But > other than a missing `const` on the `for-of`, it looks nice and efficient -- > except that [it doesn't seem like `for-of` on arrays with the default > iterator is much optimized yet][1]. FWIW: > > ```js > function removeFromArray(array, item) { > let changed = false; > let j, i, len, elt; > > for (j = i = 0, len = array.length; i < len; ++i) { > elt = array[i]; > if (elt === item) { > changed = true; > } else { > array[j++] = elt; > } > } > > array.length = j; > return changed; > } > ``` > > Clunkier but apparently we're optimizing for speed... > > -- T.J. Crowder > > [1]: https://jsperf.com/for-of-vs-for-with-const-binding/1 _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

