jquery - How to get the index of an Object without writing a loop javascript -


have object, has success , error objects in it. expected answer is, have ajax call wrapper, wrapper stops normal behaviour of ajax. once api gets response, response bypass wrapper , there take object , search "key", key same below object "key"

for example response.key = "01", need match key below object. can using loop. don't want write loop, because response might have thousand of values impact performance. there such way can achieve without using loops. me out basic demo example. thanks.

object:

var getvalue = {     success: {         "01":"success 1",         "02":"success 2"     },     failure: {         "03":"failure 1",         "04":"failure 2"     }, }; 

if have "success" , "failure", try:

    if (getvalue.success[response.key]) {         console.log(getvalue.success[response.key]);     } else {         console.warn(getvalue.failure[response.key]);     } 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -