_.toPairs

Retrieves all the given object's own enumerable property [ key, value ] pairs.

  1. // Underscore - also called _.pairs
  2. // Lodash - also called _.entries
  3. var result = _.toPairs({one: 1, two: 2, three: 3})
  4. console.log(result)
  5. // output: [["one", 1], ["two", 2], ["three", 3]]
  6.  
  7. // Native
  8. var result2 = Object.entries({one: 1, two: 2, three: 3})
  9. console.log(result2)
  10. // output: [["one", 1], ["two", 2], ["three", 3]]

Browser Support for Object.entries()

ChromeEdgeFirefoxIEOperaSafari
54.0 ✔14.0 ✔47.0 ✔41.0 ✔10.1 ✔