Currently code is as given below, 

```
var child_tids = [];
      $('.term-selection').each(function(index){
        var field = $(this).attr('field');
        child_tids.push($(this).val());
      });

```

I need to segregate it based on the attribute 'field'
So I tried the below

```
var child_tids = [];
          $('.term-selection').each(function(index){
            var field = $(this).attr('field');
            child_tids[field].push($(this).val());
          });

```

But it gives me the error in console "Cannot Read property push of undefined, how can I implement it?