jquery - Javascript DataSet -


function fetchjobs() { var seq_id = 2; var dataset = [{"seq_id":"1","counter":"20"},{"seq_id":"2","counter":21"}] } 

may ask how value 21 if seq_id 2 , if seq id 1, want value 20, counter value

how value of counter: based on value of seq_id:

i can think of 3 options:

  1. a traditional loop on dataset collection. check each element loop , break once find value.

  2. use array.findindex if available, or use polyfill mdn's documentation.

  3. try linq javascript (definitely overkill if need for).


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -