Hacker News new | ask | show | jobs
by Drakim 994 days ago
Would that mean that instead of obj.pipeTo() I'd have to call obj[PIPE_TO] or something like that?
1 comments

Essentially. And then have:

  Object.prototype.pipeTo = Object.prototype[PIPE_TO]
or some other name instead of `pipeTo` should there be a conflict.

JS already has a few well-known symbols like Symbol.toPrimitive that allow one to modify an object's behaviour (in this case what happens when `valueOf` or `toString` is called), so there's precedent.