Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- |==============================================================================
- | Lodash refactoring
- |==============================================================================
- | Here is my refactoring of _lodash functions. These solutions
- | are not usually any tested. Just to try my own solution.
- |
- */
- /**
- * @description Creates a new object composed with keys of a inserted object
- * @param {Object} o Source of keys and values
- * @param {Array} keys Array of strings. Keys of values for assigning to a new object
- */
- function pick(o = {}, [...keys] = []) {
- let newObj = {}
- for (let key in o) {
- keys.map(k => k === key && (newObj[k] = o[key]))
- }
- return newObj
- }
Add Comment
Please, Sign In to add comment