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

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -