title: Iterate over multidimensional array, filter and create new one in javascript
body: <p>I found <a href="https://stackoverflow.com/questions/38918253/iterate-over-a-multidimensional-javascript-array-and-create-new-array">this post</a> but it's not really what I'm looking for. I have a huge JSON file with this structure:</p>
  
  <pre><code>{
      foo: [1, 2, 3, ...],
      bar: [
          {
              name: 'abc',
              cl: 2,
              data: [
                        [[2, 4, 6], [4, 5, 6]],
                        [[5, 3, 5], [5, 7, 9]],
                        [[6, 8, 9], [6, 8, 9]],
                        ...
                    ]
          },
          {
              name: 'def',
              cl: 1,
              data: [10, 20, 30, ...]
          }
      ]
  }
  </code></pre>
  
  <p>I have a class representing the object and I can extract the properties and the objects inside the parent object. The <code>foo</code> property is mandatory while the <code>bar</code> property is optional. <code>data</code> is a numeric array that can be 1D or 3D. The <code>foo.length</code> and the <code>data.length</code> are always the same. I want to reduce the file size (in term of contents) but keeping the same structure, i.e. copy the old object to a new  with exactly the same structure but shorter, so I could define a smaller length or range and get a new object, e.g. if I say to go from <code>foo[0]</code> to <code>foo[1]</code> then the data property will also go from <code>data[0]</code> to <code>data[1]</code> in the new object.</p>
  
  <p>Is this possible? If yes, how can I achieve it? Maybe with <code>map</code>? but how?</p>
  
  <pre><code>function filter(obj, from, to){
       /// ?
  }
  </code></pre>
  
  <p>Regards.</p>
  
  <p>EDIT:</p>
  
  <p>The new reduced object should be something like this: </p>
  
  <pre><code>{
      foo: [1, 2],
      bar: [
      {
          name: 'abc',
          cl: 2,
          data: [
                    [[2, 4, 6], [4, 5, 6]],
                    [[5, 3, 5], [5, 7, 9]]
                ]
      },
      {
          name: 'def',
          cl: 1,
          data: [10, 20]
      }
  ]
  }
  </code></pre>