Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does exist a cleaner way to call a static method inside ES6 Array.filter function ?

mine(input = '') {
    var translatedAnswers = this.constructor.translate(this._defaultAnswers);
    var self = this;
    return translatedAnswers.filter(function (answer) {
        return self.constructor.match(input, answer);
    });
}
share|improve this question

With an arrow function I can avoid the var self = this;

mine(input = '') {
    const translatedAnswers = this.constructor._translate(this._defaultAnswers);
    return translatedAnswers.filter(answer => this.constructor._match(input, answer));
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.