I need to perhaps write a function that just outputs the index of an object inside an array, obviously, using $.inArray returns this just fine in the example below.
array = ['one', 'two', 'three'];
$.inArray('one', array) // 0
With a more elaborate array, How can I find the index of the objects nested within?
array = [
{
name: 'One', // index??
data: {
title: 'Title One',
content: 'Content One'
}
},
{
name: 'Two',
data: {
title: 'Title Two',
content: 'Content Two'
}
},
{
name: 'Three',
data: {
title: 'Title Three',
content: 'Content Three'
}
}
];
I've heard of the $.grep() method, indexOf() .. not sure which one to use to just return an integer of the index the object is in