get keys wher value is true in object in javascript

Solutions on MaxInterview for get keys wher value is true in object in javascript by the best coders in the world

showing results for - "get keys wher value is true in object in javascript"
Max
18 Sep 2020
1var obj = {1001: true, 1002: false};
2
3var keys = Object.keys(obj);
4
5var filtered = keys.filter(function(key) {
6    return obj[key]
7});