> This is definitely something that can be polyfilled (with different
levels of naivety) but requires modifying built-ins which is a no-no.

You can safely modify `Object.prototype` using `Symbol`.

```js
export const tap = Symbol('tap');

Object.prototype[tap] = function tap(f) {
  f(this);
  return this;
}

[1, 2, 3]
  .map(n => n * 2)
  [tap](console.log.bind(console))
  .reduce((a, b) => a + b);
```

No need to add a new method to `Array.prototype` and you can use it with
any type.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to