I would like to get 2 new arrays based on an existing array containing objects. (keys stay the same for each object)
newArray1 objects should be unique in terms of their value. In other words:
[
{Layer:"Layer",LayerName:"foo",LayerWidth:200,LayerHeight:400},
{Layer:"Layer",LayerName:"FOOBAR",LayerWidth:200,LayerHeight:400},
{Layer:"Layer",LayerName:"foo",LayerWidth:200,LayerHeight:400}
]
newArray1 should consist of 1st and 2nd object, because 3rd has the same object-values like the 1st object.
newArray2 should contain all other objects, that are not in newArray1, (3rd object only)
arr = []
for(var i=0;i<allSymbols.length;i++){
var obj={
Layer: allSymbols(i),
LayerName: allSymbols(i).name(),
LayerWidth: allSymbols(i).width(),
LayerHeight: allSymbols(i).height()
}
arr.push(obj)
}
// filter so far...
for(var u=0;u<arr.length;u++){
var filter = arr[u];
arr = arr.filter(function(item){
for(var key in filter){
if(item[key] == filter[key]){
return true
}
}
return false
});
}
// output newArray1(arr)?
// output newArray2?