My current project is built using AngularJS, Redux, and Underscore. Within this project, I have the following code snippet:
const selectedBroker = _.findWhere(state.brokers, { brokerId: action.payload });
return state.merge({
selectedBroker,
selectedBrokerId: action.payload,
});
I'd like to refactor this code using es6 methods instead. I believe utilizing find()
would be appropriate, but I'm unsure of how to implement it. Can you provide some guidance? Thanks in advance!
Although not part of my immediate task, I've noticed other underscore methods being used here such as _.reject, _.contains, _.map
. If possible, could you also demonstrate how to convert these within a similar context to the above example?