Advantage of using .bind() vs thisArg to set this in [].foreach() callback?


#1

On page 189 you recommend using .bind() to set this for the context of the .forEach() method.

Is there an advantage to this versus simply passing this as an argument to .foreach() like this?

customerIdArray.forEach(function(id) {
    console.log(this.db.get(id));
}, this);

It seems to work this way.


#2

Oh, hey, maybe I should have read the rest of the chapter first. :joy::joy::joy: