Create a copy of an object with a key renamed.
Time complexity: O(1)
Space complexity: O(1)
The key to rename
The new name for the key
A shallow-copied object with the key name updated
Object
const object = { a: 1 };rename(object, 'a', 'b'); // { b: 1 } Copy
const object = { a: 1 };rename(object, 'a', 'b'); // { b: 1 }
Create a copy of an object with a key renamed.
Time complexity: O(1)
Space complexity: O(1)