3 ms·
//here's an AJAX request and a chain of promises m.request({method: "GET", url: "/api/projects"}) .then(console.log) // log all projects .th
by gberger 13y ago
//here's an AJAX request and a chain of promises
m.request({method: "GET", url: "/api/projects"})
.then(console.log) // log all projects
.then(pastItems) // filter past projects
.then(console.log) // log past projects only
The calls to console.log will not work.
You need to do this:
.then(function() { console.log(arguments); })
Or this:
.then(console.log.bind(console))
- gonzoisme 13y agoYeah, the example couldn't work. Also, isn't this an example of partial application, not currying?
- ephemeralgomi 13y agoYup.
- judk 13y agoFunny this mistake rarely goes the other direction. Probably because 'curry' is a fin word. I propose 'parry' for "partial application", to satisfy the punsters without compromising accuracy.
- _ZeD_ 13y agowell, it depends on the console.log implementation :) On firefox I get >>> console.log.call(undefined, "Hi") Hi
- bendrucker 13y agoconsole.log is bound in Firefox and in Node. In all other browsers calling console.log.call(null) is a TypeError.
- cwmma 13y agothis console.log.bind(console) doesn't work in old IE you need to do Function.prototype.bind.call(console.log, console)