If I have an javascript object like this: {a : { b: { c: { ... }}}}, how can I find if there is an ‘x’ key in the object and what it’s value ?
If I have an javascript object like this: {a : { b: { c:
Share
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.
So long as their is no fear of cyclic references you could do the following
Note: This will search for the property ‘x’ directly in this object or it’s prototype chain. If you specifically want to limit the search to this object you can do so doing the following
And repeating for pattern for the recursive calls to
findX