javascript - how check if element exists in array? -


is there way check if track_id exists on array?
here array structure, tried use indexof.

{"playlist":[{track_id : 1}, {track_id : 2}, {track_id : 3}]} 

use array#some method

var obj = {    "playlist": [{      track_id: 1    }, {      track_id: 2    }, {      track_id: 3    }]  };    var search_id = 2;    var found = obj.playlist.some(function(v) {    return v.track_id == search_id;  });    console.log(found);


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -