# Filter array with out index

**URL:** https://discourse.nodered.org/t/filter-array-with-out-index/38563
**Category:** General
**Created:** [5 January 2021 05:07 UTC](https://discourse.nodered.org/t/filter-array-with-out-index/38563 "2021-01-05T05:07:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Paulf007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paulf007/32/26758_2.png) [@Paulf007](https://discourse.nodered.org/u/Paulf007)
#### Post date: [5 January 2021 05:07 UTC](https://discourse.nodered.org/t/filter-array-with-out-index/38563/1 "2021-01-05T05:07:26Z")

</div>

I am building a Alarm that monitors all the doors on my property and would like to get a notification at 18H00 to inform me if any of them was left open.  
I created a function that monitors the topic's and then sets their status in an array (Using collector)  
This is what the Array looks like

```auto
{
Back Door : "OPEN",
Front Door : "CLOSED",
Garage Door : "OPEN"
}

```

How do I create a filter that will list all the Objects in the array that has the value "OPEN"?

---

<div class="post-metadata">

### Author: ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)
#### Post date: [5 January 2021 05:24 UTC](https://discourse.nodered.org/t/filter-array-with-out-index/38563/2 "2021-01-05T05:24:43Z")

</div>

Hi,

That is not an Array .. its an Object .. but you can convert its values into an Array with [**Object.values()**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Object/values)

and then check if the newly created Array of values includes "OPEN" with `includes()`

[Array.includes()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)

---

<div class="post-metadata">

### Author: ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)
#### Post date: [5 January 2021 06:00 UTC](https://discourse.nodered.org/t/filter-array-with-out-index/38563/3 "2021-01-05T06:00:25Z")

</div>

You can also use the [for ... in](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in) method to iterate through an object directly and return if the value is open.

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [5 January 2021 08:32 UTC](https://discourse.nodered.org/t/filter-array-with-out-index/38563/4 "2021-01-05T08:32:35Z")

</div>

you could return the an array of keys that have the value "OPEN".

```auto
[{"id":"83c682b8.032bc","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"Back Door\":\"OPEN\",\"Front Door\":\"CLOSED\",\"Garage Door\":\"OPEN\"}","payloadType":"json","x":180,"y":2580,"wires":[["467a3774.0b20f8"]]},{"id":"467a3774.0b20f8","type":"change","z":"8d22ae29.7df6d","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"\t$keys(payload.$sift(function($v, $k) {$v = \"OPEN\"}))","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":2580,"wires":[["6d57c0db.f2671"]]},{"id":"6d57c0db.f2671","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":2480,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![Paulf007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paulf007/32/26758_2.png) [@Paulf007](https://discourse.nodered.org/u/Paulf007)
#### Post date: [5 January 2021 15:50 UTC](https://discourse.nodered.org/t/filter-array-with-out-index/38563/5 "2021-01-05T15:50:53Z")

</div>

Super thank you so much!! Now I need to go and study the code to understand what it is doing.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [19 January 2021 15:50 UTC](https://discourse.nodered.org/t/filter-array-with-out-index/38563/6 "2021-01-19T15:50:55Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
