reduce duplicate in a javascript object

I've got an object like: { a : 'foo', b : 'bar', c : 'foo', d : 'baz', e : 'bar' } I want to reduce the duplicates like: { ac : 'foo', be : 'bar', d : 'baz' } What's a good way to do that? A few caveats: - There will only ever be a small number of pairs. (Currently there are 7; I could imagine it going up to, say, 20.) - The initial property names will only ever be a single character, like in the example - The values could potentially run to several hundred characters. - both speed and code-length are highly important, but given the small number of rows, code clarity is probably still most important.

以上就是reduce duplicate in a javascript object的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准