javascript - Map object keys to array is value is true -
javascript - Map object keys to array is value is true -
i have object pks , extract keys value true
pks = {3: false, 7: true, 2: true}
is there underscore function can homecoming [7, 2]
? i've tried _.invert
lost 1 of values in process i'm looking alternative
you can builtin functions, no need underscore:
object.keys(pks) .filter(function(k){return pks[k]}) .map(number)
javascript underscore.js
Comments
Post a Comment