title: Javascript get values from multidimensional array object by other values
body: <p>I have a structure like below;</p>
  
  <pre><code>var devices = {
      'device-1' : {
        'id' :'device1',
        'template' :'template-1',
        'user-1' :{
          'name' : 'John Doe',
          'authority' : 'author1',
        },
        'admin-1' :{
          'name' : 'Bob Doe',
          'authority' : 'author2',
        },
        'user-35' :{
          'name' : 'Bill Doe',
          'authority' : 'author1',
        },
        'author-42' :{
          'name' : 'Jack Doe',
          'authority' : 'author1|author3',
        }
    },
      'device-2' : {
        'id' :'device2',
        'template' :'template-2',
        'some-27' :{
          'name' : 'John Doe',
          'authority' : 'author1',
        },
        'other-42' :{
          'name' : 'Jack Doe',
          'authority' : 'author2',
        }
    },
      'device-7' : {
        'id' :'device7',
        'template' :'template-1',
        'user-2' :{
          'name' : 'Samantha Doe',
          'authority' : 'author2',
        }
        'admin-40' :{
          'name' : 'Marry Doe',
          'authority' : 'author1',
        },
      }
  
  };
  </code></pre>
  
  <p>and I would like to get all 'value' entries of user-x elements by filtering their 'property' values.</p>
  
  <p>Eg.</p>
  
  <p>I would like filter all 'name's of users (no matter in which device and what are those user-ids) based on their 'authority' property and get <code>'John Doe','Bill Doe','Jack Doe','Marry Doe'</code> (as an array) if I would like filter for 'author1' 'authority' so I can get which users have 'author1' authorities on any devices.</p>
  
  <p>I've checked many places (including StackOverflow) but most of the examples are limited to two-dimensional object arrays, variables were specific or objects were based on an integer (like [0] => Array). </p>
  
  <p>But in this example, <code>'device-x'</code> and <code>'user-x'</code> entries are uncertain (so I cannot say their values are these) but <code>'name'</code> and <code>'authority'</code> keys are certain (assign by the system) and the count of these variables can be varied (crud operations).</p>
  
  <p>Thanks right now.</p>
  
  <p><strong>UPDATE</strong> : Because of my assumption error (I thought that if I write user-x parts different that each other, people think that these values are not follow any rule) question was not clear. So I edited in code.
  Finally : owners of 'name' and 'authority' key-value pairs are user names and they are user defined.</p>
  
  <p>So, all device objects will have id, template, unknown-user-field, but all unknown-user-fields must have 'name' and 'authority' key-value pairs.</p>