Set all Object keys to false

后端 未结 9 1482
执念已碎
执念已碎 2021-01-03 19:50

Lets say I have an object

  filter: {
    \"ID\": false,
    \"Name\": true,
    \"Role\": false,
    \"Sector\": true,
    \"Code\": false
  }
9条回答
  •  时光说笑
    2021-01-03 20:28

    A small line of code compatible with all browsers:

    for(var i in your_object) your_object[i] = false;
    

提交回复
热议问题