title: How to check if all objects in an array contains same keys and values?
body: <p>How to check if all objects in an array contains same keys and values</p>
  
  <pre><code>const arrOfObjects = [{a: 1, b: 2}, {a: 1, b: 2}, {a:1, b: 2 }] // true
  
  const arrOfObjects = [{a: 1, b: 2}, {a: 1, b: 2}, {a:2, b: 1 }] //false
  
  const arrOfObjects = [{a: 1, b: 2}, {a: 1, b: 2, c: 3}, {a:2, b: 1 }] //false
  </code></pre>
  
  <p>This is my trial that looks so ugly and bad and not working, i would be thankful if someone put an efficient code for that problem!</p>
  
  <pre><code>function test(arr){
  
     const firstItem = arr[0];
     const firstItemKeys = Object.keys(firstItem);
  
     for(let i = 0; i &lt; firstItemKeys.length; i++) {
        for(let j = 0; j &lt; arr.length; j++) {
           for(let x in arr[j]) {
               if(arr[j][x] !== firstItem[firstItemKeys[i]]) return false
           }
         }
     }
  
     return true
  }
  </code></pre>