So I have this array:
var statuses = { New:1, Addressed:2, Rejected:3, Recovered:4, Billed:5, Completed:6 };
And I’d like to basically search the array for the “Rejected” key and have it return the value, so I can then go back/forth in the array as needed.
I’ve tried this, but it always fails with a “-1” saying it can’t find it.
jQuery.inArray("Rejected", statuses)
No need for jQuery.
If you want the value, do:
This will return
undefinedif “Rejected” is not in the object.As the others have said, literals of the form
{blah: value, blah2: value}represent objects, and those like[value1, value2, value2]represent arrays.