Object.keys gets the keys from the object, then you can filter the keys based on the values
var obj = {1001: true, 1002: false};
var keys = Object.keys(obj);
var filtered = keys.filter(function(key) {
return obj[key]
});
More Related Contents:
- Most efficient method to groupby on an array of objects
- Add property to an array of objects
- Javascript group objects by property [closed]
- break array of objects into separate arrays based on a property
- Detecting an undefined object property
- Test for existence of nested JavaScript object key
- How to get the difference between two arrays of objects in JavaScript
- How to get a key in a JavaScript object by its value?
- How to create an object property from a variable value in JavaScript? [duplicate]
- Why can I add named properties to an array as if it were an object?
- How to get the size of a JavaScript object?
- JavaScript: filter() for Objects
- How to access the first property of a Javascript object?
- Object property name as number
- Sum JavaScript object propertyA values with the same object propertyB in an array of objects
- How to get objects value if its name contains dots?
- How to get object length [duplicate]
- Merge keys array and values array into an object in JavaScript
- How to sum the values of a JavaScript object?
- How to display image with JavaScript?
- Convert JavaScript array of 2 element arrays into object key value pairs
- JavaScript equivalent of jQuery’s extend method
- Count duplicates within an Array of Objects
- JavaScript, elegant way to check nested object properties for null/undefined [duplicate]
- What is the type of “keys” in JavaScript?
- How do I reference the same Object’s properties during its creation? [duplicate]
- correctly implement backbone comparators
- Find all values by specific key in a deep nested object
- Javascript oddness with array of objects and indexOf
- Dynamically Add Variable Name Value Pairs to JSON Object