简体   繁体   English

如果使用underscore.js,如何获取对象中的值列表(如果它大于特定值)

[英]How to get the list of values in an object if it is greater than specific value using underscore.js

I had an object with specific values in it with key and value. 我有一个带有键和值的特定值的对象。 I'm trying to pluck all the list by comparing to one of the value in the object. 我试图通过与对象中的值之一进行比较来选择所有列表。 My object is like 我的对象就像

var object= {one:1,two:2,three:3,four:4,five:5,six:6,seven:7}

Now, i want to pluck all the values which is greater than 3. expected output is like 现在,我要选择大于3的所有值。预期输出就像

{four:4,five:5,six:6,seven:7}.

I'm trying to achieve this using underscore.js. 我正在尝试使用underscore.js来实现。

_.pick(object, function(value, key, object) {return value > 3;});

似乎应该这样做,尽管我尚未测试过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM