How to get first n elements of an object using lodash?
问题 I want to get the first n key/value pairs from an object (not an array) using lodash. I found this answer for underscore, which says to use use first (doesn't exist in lodash), or to use take (only works on arrays). Sample node session trying to get the 'a:7' and 'b:8' pairs from an object: > var ld=require("lodash") undefined > var o={a:7, b:8, c:9} undefined > ld.keys(o) [ 'a', 'b', 'c' ] > ld.take(o, 2) [] > ld.first(o, 2) undefined > Surely, there must be some easy way to do this with