Boilerplate reduction

I find myself writing some common boilerplate patterns in my code, and have recently started using Dojo’s partial() and getObject() functions to reduce some of these:

Extract deep properties from an array of objects
Boilerplate

dojo.map(array, function(i) { return i && i.foo && i.foo.bar && i.foo.bar.baz; ));

Trick

dojo.map(array, dojo.partial(dojo.getObject, "foo.bar.baz", false));

Additionally, I stumbled across this little nugget:

Filter out “empty” elements from an array
Boilerplate

dojo.filter(array, function(i) { return !!i; ));

Trick

dojo.filter(array, Boolean);