@ou-imdt/utils
Version:
Utility library for interactive media development
9 lines • 429 B
JavaScript
/**
* Creates a new object by picking specific keys from an existing object.
* @param {Object} obj - The source object.
* @param {string[]} keys - An array of keys that should be picked from the source object.
* @returns {Object} A new object containing only the specified keys and their associated values.
*/
export default function subsetObject(obj, keys) {
return Object.fromEntries(keys.map(key => [key, obj[key]]));
}