I have some doubts regarding iteration into a JS object and some array functions in JavaScript. Let's say I have these variables:
var json1 = "[{"id": 1, "name":"x"}, {"id": 2, "name":"y"}]";
var json2 = "[{"id": 1, "name":"x"}, {"id": 2, "name":"y"}, {"id": 3, "name":"z"}]";
How can I create a variable with only identifiers in an array
var ids1 = json1.ids (would be 1,2)
var ids2 = json2.ids (would be 1,2,3)
and make another variable only with identifiers that are different from each other
var idsdiff = diff(ids1, ids2) (would be 3)
source
share