I am trying to get all the keys and values of an object that begin with imageIds.
My object appears as the following:
{
title: \'fsd
Along the lines of the answer from @zerkms, I've been working on a functional programming library for Javascript. With the tools from that library, this turns into a (somewhat dense) one-liner:
var data = {
title: 'fsdfsd',
titleZh: 'fsdfsd',
body: 'fsdf',
bodyZh: 'sdfsdf',
imageIds: '/uploads/tmp/image-3.png',
imageIdsZh: ''
};
var x = pick(filter(compose(eq("imageIds"), substring(0,8)), keys(data)), data);
console.log(x);
This code is not necessarily any better than what @zerkms posted, but it does show off some more of the power of functional abstractions beyond the few that are built into Array.prototype.
You can see it in action on JSFiddle.