I have two arrays in angular.
One is regular array A with values ['Stock_Number', 'Model', 'Type', 'Bill_Number']
Another is associated array B like the following
0:[
{
'Stock_Number': 'GTH738',
'Model': 'sample_model',
'Type': 'sample_type',
'Bill_Number': 7784754,
'some_prop1': 'prop1_val',
'some_prop2': 'prop2_val'
}
];
Both arrays are dynamic. Also B has more columns than A. A has the keys of B's(A is subset of B) I want to get a new array C only for elements in A. For this I'm checking if key exists in B. Following is my code
for(var i=0,j=0; i<B.length,j<A.length; i++,j++){
if (!B.hasOwnProperty(A)) {
var value = A[j];
console.log('if-'+value); //printing value
console.log(B[0].value); // printing undefined
// C.push(B[0].value);
}else{
//some code
}
}
Resulting array should be something like the following
{
'Stock_Number': 'GTH738',
'Model': 'sample_model',
'Type': 'sample_type',
'Bill_Number': 7784754
}
Can somebody suggest me how this can be achieved?
{ 0: [{'Stock_Number' ...? The 0 is the property?