Hi all,
I’m trying to use the array method “forEach” but not sure if I’m using it correctly as I keep getting “…not a function”.
So I converted an AJAX response to JSON and want to insert each item into an array. Im doing it this way so I can minimize the stuff that’s not useful to me.
I’m trying to use a forEach on the response JSON to push each object into the array by using this code:
But this isn’t working, wondering if anyone could explain what I’m doing wrong and how to accomplish what I’m after.
Any help would be greatly appreciated
I’m trying to use the array method “forEach” but not sure if I’m using it correctly as I keep getting “…not a function”.
So I converted an AJAX response to JSON and want to insert each item into an array. Im doing it this way so I can minimize the stuff that’s not useful to me.
I’m trying to use a forEach on the response JSON to push each object into the array by using this code:
JavaScript:
array.forEach(function(){
array2.push(this);
});
But this isn’t working, wondering if anyone could explain what I’m doing wrong and how to accomplish what I’m after.
Any help would be greatly appreciated