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?

Menu