Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const aliasProperty = (source, target) => object => {
- object[target] = object[source];
- return object;
- };
- // Example
- const aliasIdToValue = aliasProperty('id', 'value');
- aliasIdToValue({ id: 123, name: 'Hello' });
- const categories = [
- { id: 123, name: 'Hello' },
- { id: 456, name: 'Bye' }
- ];
- categories.map(aliasIdToValue);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement