I have an object and would like to get the first n items using underscore (map/each anything)
Below is the code:
var input = {
a:1,
b:2,
c:3,
d:4
}
_.map(input, function (value, key, index) {
if(index < 2) {
console.log(key + ' == ' + value)
}
});
Output should be like like [{a:1}, {b:2}...]