Wednesday 31 May 2017

Compare two different array elements remove the match elements in node js

I have two array objects as below:

var arrayOne = [{"Name":"job","SubscriptionGUID":"8ead7edfa460"},{"Name":"TestJobSQL","SubscriptionGUID":"09e7dbff7779"}];
var arrayTwo = [{"UserSubscriptionID":13,"SubscriptionGUID":"8ead7edfa460","Name":"job"}];
var arrayDiff = [];

I need to compare the element Name and remove matched element only show not matching array element in arrayDiff

as per above example My new arrayDiff should be

var arrayDiff = [{"Name":"TestJobSQL"}]; or var arrayDiff = ['TestJobSQL'];

if the arrayTwo is

var arrayTwo = [];

then arrayDiff should return

var arrayDiff = [{"Name":"TestJobSQL"},{"Name":"Job"}]; or  var arrayDiff = ['TestJobSQL', 'Job'];



via Mukesh25

No comments:

Post a Comment