A little problem with the array

var arr = [
    {
      type: 1,
      age: 12,
      name: "xiaohua"
    },
    {
      type: 1,
      age: 12,
      name: "xiaoming"
    },
    {
      type: 1,
      age: 12,
      name: "xiaohong"
    },
    {
      type: 2,
      age: 14,
      name: "xiaoxiao"
    },
  ]

how to judge the equal items of type and age in an array

Mar.28,2021

let arr = [
    {
      type: 1,
      age: 12,
      name: 'xiaohua'
    },
    {
      type: 1,
      age: 12,
      name: 'xiaoming'
    },
    {
      type: 1,
      age: 12,
      name: 'xiaohong'
    },
    {
      type: 2,
      age: 14,
      name: 'xiaoxiao'
    },
    {
      type: 11,
      age: 11,
      name: 'xixi'
    },
]
const res = arr.filter(ele=>ele.type===ele.age);
console.log(res);

like this?


  

what effect do you want to achieve? Cycle through it?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5b76d-4562c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5b76d-4562c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?