As per the tutorial here,
A collection can either be an array or an object, an associate array
in JavaScript
does that mean all the functions under collection
is equally applicable to object literals.
For example, I wanted to pick the values based on a condition. Say,
var obj = {
1: {id: 1, val: 2},
2: {id: 2, val: 5},
3: {id: 3, val: 8},
4: {id: 4, val: 1}
}
I want to find max and min of val field. Looking at the API, I was thinking to use pluck
to get an array of val
, then do min
and max
.
- can I apply pluck to object (as the api example show the use in an array of objects)
- is there a better way?
Thanks.