'how to split the array objects into same array based on reapeted object elements

Say i have an array like this :

 var arr=[
 
 {
  "favnumber": 20,
  "studentname": "mohan",
  "Studentage": 18
  },
 {
   "favnumber": 22,
   "studentname": "mahesh",
  "Studentage": 19
 },
 {
  "favnumber": 22,
  "studentname": "emam",
  "Studentage": 19
  },
 {
  "favnumber": 20,
  "studentname": "mamtha",
  "Studentage": 18
 }

]; 

now i have to split the objects based on the repeated object keys : i have tried many methods could not resolve . expected output:

  [
  {
   "favnumber": 20,
  "studentname": "mohan",
  "Studentage": 18
  },
  {
  "favnumber": 22,
  "studentname": "mahesh",
  "Studentage": 19
  }
  ],
  [
  {
  "favnumber": 22,
  "studentname": "emam",
  "Studentage": 19
   }
   ],
   [
   {
  "favnumber": 20,
  "studentname": "mamtha",
  "Studentage": 18
    }
    ]
    

now i have to split the objects based on the repeated object keys : now i have to split the objects based on the repeated object keys :

thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source