Is there a way to get one object property from the value of another property
for example (in SQL) Get id from object where object.name=”somename” ?
I need to get the id of that object, but I only know the name.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I will assume you are trying to do this with an array of objects, because it doesn’t make sense otherwise.
Depending on your desired browser support there is a method called
filteronArray.prototype. If needed you can shim it too.The code would end up looking something like this:
Here is a jsfiddle link: http://jsfiddle.net/g8rTA/