Object keys to lowercase I wrote a small snippet to convert object keys to lowercase. I would like to listen about the ways to improve the following code:

function toLowerCaseKeys(obj) {
  return Object.keys(obj).reduce(function(accum, key) {
    accum[key.toLowerCase()] = obj[key];
    return accum;
  }, {});
}

console.clear();
console.log(toLowerCaseKeys({'Foo': true}).foo);
console.log(toLowerCaseKeys({'FoO': true}).foo);
If you can go ES6, you can get a more concise version:

Object.keys(o).reduce((c, k) =&gt; (c[k.toLowerCase()] = o[k], c), {});


Now, if one or more strings lowercase into the same string, expect only one of them to remain.