Here's my code:
headersObj = {a: "a", b: "b", c: "c"};
headers = ["a", "b", "c"];
fields = ["a", "b"];
notInTemplate = [];
headers.forEach(function(obj) {
if(fields.indexOf(obj) == '-1'){
console.log(headersObj.c);
console.log(headersObj.obj);
console.log(obj);
notInTemplate.push(obj);
}
});
console.log(notInTemplate);
I could explain more about my use case, but I just want to be able to "headersObj" property, so I can push it to the "notInTemplate" array. I've distilled it to this fairly simple example. The output of which is:
c undefined c [ 'c' ]
Why is the object property undefined?