Dev Console showing TypeError on forEach (js)


So I’m getting a TypeError for this method when it runs in the web dev console, however I’m not getting any errors in actual code, and can’t seem to find the problem with this. I’m basically doing exactly what it does here, so I can’t figure out what seens to be the problem. Here’s the code:

parse(response) {
    response.forEach(function (customer){ //this gives a TypeError!
        if (customer.LastName) {
            customer.LastName = customer.LastName.charAt(0);

    return response;

Response is an array so I feel like it should be working??

Here’s the error message:

Uncaught TypeError: response.forEach is not a function
parse @ customersCollection.es6.js:37
_.extend.set @ backbone.js?
options.success @ backbone.js?
fire @ jquery.js?
self.fireWith @ jquery.js?
done @ jquery.js?
callback @ jquery.js?

I’m still new to Javascript and callback functions so any input would be great. Thanks a bunch in advance!!

Link: Dev Console showing TypeError on forEach (js)
Source: Stack Jquery


About Author

Leave A Reply