Set all Object keys to false

Well here's a one-liner with vanilla JS:

Object.keys(filter).forEach(v => filter[v] = false)

It does use an implicit loop with the .forEach() method, but you'd have to loop one way or another (unless you reset by replacing the whole object with a hardcoded default object literal).


Using lodash, mapValues is a graceful, loop-free way:

filter = {
    "ID": false,
    "Name": true,
    "Role": false,
    "Sector": true,
    "Code": false
};

filter = _.mapValues(filter, () => false);

If you want to do this with Underscore.js, there is an equivalent, but with a slightly different name:

filter = _.mapObject(filter, () => false);

In either case, the value of filter will be set to:

{ ID: false, 
  Name: false, 
  Role: false, 
  Sector: false, 
  Code: false }