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:
a traditional loop on
dataset
collection. check each element loop , break once find value.use
array.findindex
if available, or use polyfill mdn's documentation.try linq javascript (definitely overkill if need for).
Comments
Post a Comment