# Weird array filter behavior

**URL:** <https://forum.wixstudio.com/t/weird-array-filter-behavior/10824>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [February 23, 2021, 10:12pm UTC](https://forum.wixstudio.com/t/weird-array-filter-behavior/10824 "2021-02-23T22:12:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodneyelliott](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rodneyelliott](https://forum.wixstudio.com/u/rodneyelliott)\
**Post date:** [February 23, 2021, 10:12pm UTC](https://forum.wixstudio.com/t/weird-array-filter-behavior/10824/1 "2021-02-23T22:12:50Z")

</div>

I am attempting to produce an array containing all the Groups on a page. The groups have IDs such as #gTag1, #gTag2 etc, and I am using the following code:

```javascript
let pageChildren = $w("Page").children;
console.log(pageChildren);

function checkGroup(grp) {
  let grpMatch = /gTag/;
  return grpMatch.test(grp);
}

let tagIds = pageChildren.filter(checkGroup);
console.log(tagIds);

```

This returns an empty array, yet if I copy and paste the output of “console.log(pageChildren)” into the Velo code as follows:

```javascript
let pageChildren = [
  "$w('#text1')",
  "$w('#line1')",
  "$w('#bHelp')",
  "$w('#bReset')",
  "$w('#dQuantity')",
  "$w('#dFont')",
  "$w('#dAlignment')",
  "$w('#gTag1')",
  "$w('#gTag2')",
  "$w('#gTag3')",
  "$w('#gTag4')",
  "$w('#bBuy')",
  "$w('#bBacker')",
  "$w('#iSize')"
];

function checkGroup(grp) {
  let grpMatch = /gTag/;
  return grpMatch.test(grp);
}

let tagIds = pageChildren.filter(checkGroup);
console.log(tagIds);

```

The filter works. Why does it not work in the first instance?

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [February 24, 2021, 12:00am UTC](https://forum.wixstudio.com/t/weird-array-filter-behavior/10824/2 "2021-02-24T00:00:45Z")

</div>

The first one is an array of elements (objects). The second one is an array of strings. So it’s supposed to behave differently.
