Skip to content Skip to sidebar Skip to footer

Keyword Function Is Necessary In The Following Codes:

My backbone View: module.exports = Backbone.View.extend({ tagName: 'div', events: { 'click #saveReportBtn': '_handleSaveReport', 'click #saveQuery': '_handleSaveQuery',

Solution 1:

The shorthand you are using:

_enter( event ) {
    console.log('event target:', + event.target.name + ', ' + event.currentTarget.name); // eslint-disable-line no-console
  }

Is ES2015 (ES6) shorthand which is why eslint doesn't complain. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions

Specifically:

Note : The shorthand syntax uses named function instead of anonymous functions (as in …foo: function() {}…).

Try adding a function name to your assignment. (http://eslint.org/docs/rules/func-names)

 _enter: function _enter( event ) {
    console.log('event target:', + event.target.name + ', ' + event.currentTarget.name); // eslint-disable-line no-console
  }

Having named functions, rather than anonymous functions floating around really help with the debugging process and more explicit stack traces


Post a Comment for "Keyword Function Is Necessary In The Following Codes:"