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

Popular posts from this blog

php - How to pass multiple values from url -

database - php search bar when I press submit with nothing in the search bar it shows all the data -

ios - How to load .png images from Documents folder of an app -