About underscore.map

javascript, underscore.js

Solution

You actually want to use `_.pick` and `_.values`:

_.values( _.pick( obj, "one", "two" ) )

Problem

I have the following object ``` {one : 1, two : 2, three : 3} ``` and I would like ``` [1,2] ``` Here my code ``` _.map({one : 1, two : 2, three : 3}, function(num, key){ if (key==='one' || key==='two') { return num; } }); // [1, 2, undefined] ``` Actually I would like `[1,2]` How can I improve my code? thanks

Original source