Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

rename object keys javascript

function renameKeys(obj, newKeys) {
  const keyValues = Object.keys(obj).map(key => {
    const newKey = newKeys[key] || key;
    return { [newKey]: obj[key] };
  });
  return Object.assign({}, ...keyValues);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #rename #object #keys #javascript
ADD COMMENT
Topic
Name
3+6 =