Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find a value into an Array of Obects

I have an Array of Objects in Javascript:

function focal( name, data )
{
    this.name = name;
    this.data = data;
}

count = 0;

arrayFocal = [];
arrayFocal[count] = new focal( "Name", "12/08/2014" );
count++;

Now I want to find into arrayFocal by name
NOTE: IE 8

like image 203
Lugarini Avatar asked Dec 21 '25 02:12

Lugarini


1 Answers

You can use filter

arrayFocal.filter(function(obj){
    return obj.name=='Name';
});

It will return an array of objects which name matched. If you want just first one you can [0] for that.

like image 133
Mritunjay Avatar answered Dec 22 '25 15:12

Mritunjay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!