ga-wdi-boston / js-function-context-this

Other
0 stars 126 forks source link

Prefer function expression assignment to function declaration #15

Closed gaand closed 7 years ago

gaand commented 8 years ago

So this:

const goBoom = function () {
  console.log(this);
};

not this:

function goBoom () {
  console.log(this);
};
payne-chris-r commented 8 years ago

Is there any reason we might want to show them this so Ember convention doesn't look so different?

function goBoom () {
  console.log(this);
};
jrhorn424 commented 8 years ago

@payne-chris-r That's not what we do in Ember?

Everything in Ember is modifying prototypes. What we do in Ember is actually:

// note the enclosing object
exports default Ember.Object.extend({
  goBoom () {
    console.log(this);
  },
});
jrhorn424 commented 8 years ago

I'm in agreement with @gaand that these examples should change to expressions not declarations.