So we can debate how often you’d need to curry a function, but I feel safe suggesting that writing your own curry function (or reading along with an essay that does the same with lively interest) is valuable.
Same with things like classes and mixins, there is now syntactic sugar for such things, but it’s always a good thing to have written your own MakeClass function at least once.
That was kind of my intent (learning exercise rather than super practical real-world technique) -- but I'll admit I probably could have picked a better title.
https://web.archive.org/web/20140714014530/http://hughfdjack...
Ramdajs: http://ramdajs.com/0.16/index.html
objects.map(get('id'))
and poof there goes your type safety. Optional typing (flow and TS) is making inroads into JS. If you want to bet on them (or any other JS inspecting tools), make sure you use this: objects.map(function (x) { return x.id; });
Or, in ES6 or TypeScript: objects.map(x => x.id)
This helps computers understand your code.However, it's the kind of bet I wouldn't go long on. Today, TS automatically (and correctly) infers the type of objs.map(x => x.foo). I suppose the same holds true for flow. This is not hypothetical; try this in http://www.typescriptlang.org/Playground
var objects = [
{
id: 1,
name: "Foo"
},
{
id: 2,
name: "Bar"
}
];
var look_at_my_type = objects.map(x => x.id);
Note; this is 100% JS, just passed through a TS compiler.Check the type of look_at_my_type (e.g. start typing its name at the bottom, see what the popover says): number[].
Replace it by get('id') (with definition function get(name: string) { return x => x[name]; }), and the type becomes any[].
There are infinite examples for this sort of thing in real development scenarioes