get max length of characters of a value from json jquery without loop? -
i have json, want maximum count of characters value under specific tag without each or loop, possible?
{ "language": { "ru": [ { "from": "set", "to": 444 }, { "from": "sc", "to": 222 } ], "he": [ { "from": "trdsss", "to": 3333333 }, { "from": "ahsss", "to": 55555 } ] } }
let me explain exact requirement, have maximum length of string under "ru", ru has maximum lenght 3 i.e. "set" don't want string, want max. length. "he" 6 "trdsss".
i can looping, don't want go in way, there other way can this. please me.. how can it.
no, can't avoid looping. can avoid writing for
loop (say) using array#reduce
or array#foreach
, something, somewhere, going have loop.
when asked why wanted avoid looping, said
because method call number of times, trying skipping looping
and when asked if repeated calls same data, said
yes data same comes json once
so if it's important avoid repeating loops (it isn't, be), you'd loop first time , remember result reuse in subsequent calls. that's straightforward write.
Comments
Post a Comment