I have an array of objects and I want to get [152,153,154,155,156,157] which are the values for the intento
property of each object. I would get it by going through for
, but I want to know if there is a function to make it easier.
let arr= [{intento: 152, tipo: "intruso"},
{intento: 153, tipo: "intruso"},
{intento: 154, tipo: "intruso"},
{intento: 155, tipo: "intruso"},
{intento: 156, tipo: "intruso"},
{intento: 157, tipo: "intruso"}]
let copy=[];
for(let i=0; i<arr.length; i++){
copy.push(arr[i].intento);
}
console.log(copy);