//Pipe definition: Object.defineProperty(Object.prototype, 'pipe',{ value: function(...f){ return f.reduce((val, fun) => fun(val), this)}, writable: true, configurable: true, enumerable: false }); //Easier logging to console: log = console.log; Object.prototype.log = function(){ log(this.toString())}; //Our functions for piping: doubleSay = x => x + ", " + x exclaim = x => x + "!" capitalize = x => x[0] = x[0].toUpperCase() + x.slice(1) //Displaying: "Hello, hello!" in console: "hello" .pipe(doubleSay) .pipe(exclaim) .pipe(capitalize) .log() //hello = "Hello, hello!" hello = "hello".pipe(doubleSay,exclaim,capitalize)