有没有简单的方法从值中获取键?
var arr = [1,2,3,4,10];
if(_.contains(arr, 3))
alert(KEY of 3 (2))
最佳答案
向左看
找到
_.indexOf
:
_.indexOf(array, value, [isSorted])
Returns the index at which value can be found in the array, or -1 if value is not present in the array.
关于javascript - Underscore.js 从数组中的值中获取键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29122627/