I have the below type of two arrays, I want to check both array(array1
and array2
) and create another array(array3
), which has a value, which are not available into array1
.
For ex - 'mob2', 'pin', 'address2', 'city'
are available in array1
but not in array2
. I want to those array keys and values in array3
.
let array3 = [];
let array1 = {
'fname': 'test text',
'lname': 'test text',
'pin': 856,
'address1': 'test text',
'address2':'test text',
'city': 'test text',
'mob1': 35343434343,
'mob2': 34343434343
};
let array2 = ['fname','lname','mob1','address1'];
Expected Output:
array3['mob2'] = 34343434343;
array3['pin'] = 856;
array3['address2'] = 'test text';
array3['city'] = 'test text';