Guest User

Untitled

a guest
Mar 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. /*
  2. |==============================================================================
  3. | Lodash refactoring
  4. |==============================================================================
  5. | Here is my refactoring of _lodash functions. These solutions
  6. | are not usually any tested. Just to try my own solution.
  7. |
  8. */
  9.  
  10.  
  11.  
  12. /**
  13. * @description Creates a new object composed with keys of a inserted object
  14. * @param {Object} o Source of keys and values
  15. * @param {Array} keys Array of strings. Keys of values for assigning to a new object
  16. */
  17. function pick(o = {}, [...keys] = []) {
  18. let newObj = {}
  19. for (let key in o) {
  20. keys.map(k => k === key && (newObj[k] = o[key]))
  21. }
  22. return newObj
  23. }
Add Comment
Please, Sign In to add comment