是否有可能获得您在Underscore.js中排序的索引? [英] Is it possible to get the index you're sorting over in Underscore.js?
本文介绍了是否有可能获得您在Underscore.js中排序的索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用JS库下划线,特别是使用 _。每个
和 _ .sortby
库调用。我想知道是否有任何可能的方法来获取迭代器委托中的值的索引
I'm using the JS library Underscore and in particular using the _.each
and _.sortby
library calls. I'm wondering if there's any possible way to get the index of the value within the iterator delegate
_.sortBy([1, 4, 2, 66, 444, 9], function(num){
/*It'd be great to have access to the index in here */
return Math.sin(num);
});
推荐答案
索引实际上可用;
_.sortBy([1, 4, 2, 66, 444, 9], function(num, index){ });
这篇关于是否有可能获得您在Underscore.js中排序的索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文